diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_syntax.rb | 23 |
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 |