From 30257ef4dc851f137ecebe5838e4e34da78fbe52 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 11 Mar 2017 14:25:54 +0000 Subject: merge revision(s) 57240: [Backport #13090] vm.c: fix return in lambda * vm.c (invoke_block_from_c_splattable): pass lambda-ness. * vm_eval.c (yield_under): invoke lambda proc properly. [ruby-core:78917] [Bug #13090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_lambda.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index c65169ac27..c47351886a 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -79,6 +79,26 @@ class TestLambdaParameters < Test::Unit::TestCase end end + def test_instance_eval_return + bug13090 = '[ruby-core:78917] [Bug #13090] cannot return in lambdas' + x = :ng + assert_nothing_raised(LocalJumpError) do + x = instance_eval(&->(_){return :ok}) + end + ensure + assert_equal(:ok, x, bug13090) + end + + def test_instance_exec_return + bug13090 = '[ruby-core:78917] [Bug #13090] cannot return in lambdas' + x = :ng + assert_nothing_raised(LocalJumpError) do + x = instance_exec(&->(){return :ok}) + end + ensure + assert_equal(:ok, x, bug13090) + end + def yield_1(arg) yield arg end -- cgit v1.2.3