From 525336fcc97a0c0fc8dae2e6f9fe63dfc6e645ab Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 29 Oct 2003 17:47:24 +0000 Subject: * 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 --- test/ruby/test_iterator.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/ruby/test_iterator.rb') diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 60bfad50a9..c8631653f3 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -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? -- cgit v1.2.3