From 1135cc3596e301495d2fa2230cd3411fd1f516a5 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 12 Jun 2013 15:03:22 +0000 Subject: merge revision(s) 41019,41020,41021,41041,41045,41057: [Backport #8463] vm_insnhelper.c: add comments * vm_insnhelper.c (vm_yield_setup_block_args): break a long line and add comments. remove useless code. * vm_insnhelper.c (vm_yield_setup_block_args): split single parameter if any keyword arguments exist, and then extract keyword arguments. [ruby-core:55203] [Bug #8463] * compile.c (iseq_set_arguments): not a simple single argument if any keyword arguments exist. [ruby-core:55203] [Bug #8463] * vm_insnhelper.c (vm_yield_setup_block_args): partially revert r41019. The code is not useless. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_keyword.rb | 9 ++++++++- test/ruby/test_yield.rb | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 05b3e06de1..8a00128605 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -263,9 +263,16 @@ class TestKeywordArguments < Test::Unit::TestCase def test_rest_keyrest bug7665 = '[ruby-core:51278]' + bug8463 = '[ruby-core:55203] [Bug #8463]' expect = [*%w[foo bar], {zzz: 42}] assert_equal(expect, rest_keyrest(*expect), bug7665) - assert_equal(expect, proc {|*args, **opt| next *args, opt}.call(*expect), bug7665) + pr = proc {|*args, **opt| next *args, opt} + assert_equal(expect, pr.call(*expect), bug7665) + assert_equal(expect, pr.call(expect), bug8463) + pr = proc {|a, *b, **opt| next a, *b, opt} + assert_equal(expect, pr.call(expect), bug8463) + pr = proc {|a, **opt| next a, opt} + assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) end def test_bare_kwrest diff --git a/test/ruby/test_yield.rb b/test/ruby/test_yield.rb index 3337aea078..143ee55a9f 100644 --- a/test/ruby/test_yield.rb +++ b/test/ruby/test_yield.rb @@ -379,4 +379,15 @@ class TestRubyYieldGen < Test::Unit::TestCase } end + def test_block_with_mock + y = Object.new + def y.s(a) + yield(a) + end + m = Object.new + def m.method_missing(*a) + super + end + assert_equal [m, nil], y.s(m){|a,b|[a,b]} + end end -- cgit v1.2.3