summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-21 01:58:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-21 01:58:32 +0000
commit342f10b9b3579378d0983312c1f52c4c23029283 (patch)
tree8c934212a467097d67b90cfb6913be00889afae3 /test
parent581b995c54fe468e4977f8771a4ddb36ba4921ce (diff)
compile.c: toplevel return
* compile.c (iseq_compile_each): stop execution of the current source by toplevel return. [ruby-core:36785] [Feature #4840] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index f3db9bcd48..3e6212e27c 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -926,6 +926,29 @@ eom
assert_equal(:ok, result)
end
+ def test_return_toplevel
+ feature4840 = '[ruby-core:36785] [Feature #4840]'
+ code = "#{<<~"begin;"}\n#{<<~"end;"}"
+ begin;
+ return; raise
+ begin return; rescue SystemExit; exit false; end
+ begin return; ensure exit false; end
+ begin ensure return; end
+ begin raise; ensure; return; end
+ begin raise; rescue; return; end
+ return false; raise
+ return 1; raise
+ end;
+ all_assertions(feature4840) do |a|
+ code.each_line do |s|
+ s.chomp!
+ a.for(s) do
+ assert_ruby_status([], s, proc {RubyVM::InstructionSequence.compile(s).disasm})
+ end
+ end
+ end
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end