diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-30 02:16:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-30 02:16:15 +0000 |
commit | e95e524782360babafc9d3754bbbda4f266bea98 (patch) | |
tree | 8e82ceabca8055a955fa49e2013adafcc3cf3cb1 /test/ruby | |
parent | 44d2958e3b6ba71de033b7f84960c3283558f755 (diff) | |
download | ruby-e95e524782360babafc9d3754bbbda4f266bea98.tar.gz |
vm_insnhelper.c: allow to_ary
* vm_insnhelper.c (vm_callee_setup_arg{_complex,}): try conversion
by to_ary for a lambda, as well as a proc.
[ruby-core:65887] [Bug #9605]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_lambda.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 40a6b84021..0f3382ce78 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -71,6 +71,32 @@ class TestLambdaParameters < Test::Unit::TestCase assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]} end + def yield_1(arg) + yield arg + end + + tap do |;bug9605, expected, result| + bug9605 = '[ruby-core:65887] [Bug #9605] arity check should be relaxed' + expected = [1,2,3] + + [ + ["array", expected], + ["to_ary", Struct.new(:to_ary).new(expected)], + ].product \ + [ + ["proc", proc {|a, b, c| [a, b, c]}], + ["lambda", lambda {|a, b, c| [a, b, c]}], + ] do + |(vtype, val), (btype, block)| + define_method("test_yeild_relaxed(#{vtype},&#{btype})") do + result = assert_nothing_raised(ArgumentError, bug9605) { + break yield_1(val, &block) + } + assert_equal(expected, result, bug9605) + end + end + end + def foo assert_equal(nil, ->(&b){ b }.call) end |