From ffd3cbdc759841c984ec35bfecfb9f7ed28d4faa Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 13 Nov 2012 08:34:43 +0000 Subject: * vm_insnhelper.c (vm_caller_setup_args): save and restore ci->argc and ci->blockptr before and after method invocations because these method dispatches override call_info. * bootstraptest/test_method.rb: add tests for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/test_method.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'bootstraptest/test_method.rb') diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index d6b8c0ea24..ed22608aea 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -1204,3 +1204,61 @@ assert_equal 'ok', %q{ 'ok' end } + +assert_equal 'DC', %q{ + $result = [] + + class C + def foo *args + $result << 'C' + end + end + class D + def foo *args + $result << 'D' + end + end + + o1 = $o1 = C.new + o2 = $o2 = D.new + + args = Object.new + def args.to_a + test1 $o2, nil + [] + end + def test1 o, args + o.foo(*args) + end + test1 o1, args + $result.join +} + +assert_equal 'DC', %q{ + $result = [] + + class C + def foo *args + $result << 'C' + end + end + class D + def foo *args + $result << 'D' + end + end + + o1 = $o1 = C.new + o2 = $o2 = D.new + + block = Object.new + def block.to_proc + test2 $o2, %w(a, b, c), nil + Proc.new{} + end + def test2 o, args, block + o.foo(*args, &block) + end + test2 o1, [], block + $result.join +} -- cgit v1.2.3