From 9835c61bc956e5e7b40b770b6991d5386b6f86ed Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 13 Aug 2003 10:31:33 +0000 Subject: * eval.c (POP_BLOCK): turn on BLOCK_LEFT flag when leaving block. * eval.c (proc_invoke): unpack return/break destination when block is already left. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/test.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sample') diff --git a/sample/test.rb b/sample/test.rb index 6d2a6cde9..8b8354ad5 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1033,6 +1033,34 @@ test_ok(get_block(&lambda).class == Proc) test_ok(Proc.new{|a,| a}.call(1,2,3) == 1) argument_test(true, Proc.new{|a,|}, 1,2) +def test_return1 + Proc.new { + return 55 + }.call + 5 +end +test_ok(test_return1() == 55) +def test_return2 + lambda { + return 55 + }.call + 5 +end +test_ok(test_return2() == 60) + +def proc_call(&b) + b.call +end +def proc_yield() + yield +end +def proc_return1 + proc_call{return 42}+1 +end +test_ok(proc_return1() == 42) +def proc_return2 + proc_yield{return 42}+1 +end +test_ok(proc_return2() == 42) + def ljump_test(state, proc, *args) x = state begin -- cgit