From 1d8ce92a37df9e8c1f9a68de82fee8c9b3e66af6 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 3 Jul 2007 18:58:42 +0000 Subject: * compile.c (iseq_compile_each): support v[&b]= type method call. [ruby-dev:31094] * bootstraptest/test_method.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/test_method.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bootstraptest/test_method.rb') diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index faf3d4bc58..c95eec175e 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -318,6 +318,25 @@ assert_equal '1', %q( class C; def m() 7 end; private :m end assert_equal '1', %q( class C; def m() 1 end; private :m end C.new.funcall(:m) ) +# with block +assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]', +%q{ + class C + def [](a) + $ary << [yield, a] + end + def []=(a, b) + $ary << [yield, a, b] + end + end + + $ary = [] + C.new[:foo, &lambda{:ok1}] + C.new[:foo, &lambda{:ok2}] = :bar + $ary +} + + # splat and block arguments assert_equal %q{[[[:x, :y, :z], NilClass], [[1, :x, :y, :z], NilClass], [[1, 2, :x, :y, :z], NilClass], [[:obj], NilClass], [[1, :obj], NilClass], [[1, 2, :obj], NilClass], [[], Proc], [[1], Proc], [[1, 2], Proc], [[], Proc], [[1], Proc], [[1, 2], Proc], [[:x, :y, :z], Proc], [[1, :x, :y, :z], Proc], [[1, 2, :x, :y, :z], Proc]]}, %q{ def m(*args, &b) -- cgit v1.2.3