1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (proc_invoke): single array value to normal Proc#call

(i.e. not via lambda call), should be treated just like yield.
  [ruby-dev:21726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-10-29 17:47:24 +00:00
parent 2e0b6e28ad
commit 525336fcc9
8 changed files with 71 additions and 27 deletions

View file

@ -328,6 +328,32 @@ class TestIterator < Test::Unit::TestCase
lambda(&get_block{|a,n| assert(a,n)}).call(true, "marity")
end
def foo
yield([:key, :value])
end
def bar(&blk)
blk.call([:key, :value])
end
def test_yield_vs_call
foo{|k,v| assert_equal([:key, :value], [k,v])}
bar{|k,v| assert_equal([:key, :value], [k,v])}
end
class H
def each
yield [:key, :value]
end
end
def test_assoc_yield
[{:key=>:value}, H.new].each {|h|
h.each{|a| assert_equal([:key, :value], a)}
h.each{|*a| assert_equal([[:key, :value]], a)}
h.each{|k,v| assert_equal([:key, :value], [k,v])}
}
end
class ITER_TEST1
def a
block_given?