From 163f9abe4f2ba66ef433b327e0ceb2edb249e3ae Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 13 Mar 2014 16:18:45 +0000 Subject: vm_insnhelper.c: relax arity check * vm.c (invoke_block_from_c): add splattable argument. * vm.c (vm_invoke_proc): disallow to splat when directly invoked. * vm_insnhelper.c (vm_callee_setup_arg_complex, vm_callee_setup_arg): relax arity check of yielded lambda. [ruby-core:61340] [Bug #9605] * test/ruby/test_yield.rb (TestRubyYieldGen#emu_bind_params): no longer raise ArgumentError when splatting to lambda. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_lambda.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/ruby/test_lambda.rb') diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index f45ca6af71..40a6b84021 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -25,8 +25,13 @@ class TestLambdaParameters < Test::Unit::TestCase def test_lambda_as_iterator a = 0 2.times(&->(_){ a += 1 }) - assert_equal(a, 2) + assert_equal(2, a) assert_raise(ArgumentError) {1.times(&->(){ a += 1 })} + bug9605 = '[ruby-core:61468] [Bug #9605]' + assert_nothing_raised(ArgumentError, bug9605) {1.times(&->(n){ a += 1 })} + assert_equal(3, a, bug9605) + assert_nothing_raised(ArgumentError, bug9605) {a = [[1, 2]].map(&->(x, y) {x+y})} + assert_equal([3], a, bug9605) end def test_call_rest_args @@ -60,6 +65,12 @@ class TestLambdaParameters < Test::Unit::TestCase assert_nil(b) end + def test_call_block_from_lambda + bug9605 = '[ruby-core:61470] [Bug #9605]' + plus = ->(x,y) {x+y} + assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]} + end + def foo assert_equal(nil, ->(&b){ b }.call) end -- cgit v1.2.3