summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-07-22 14:01:55 +0900
committernagachika <nagachika@ruby-lang.org>2023-07-22 14:01:55 +0900
commitb97a744a3778abe52fffb051e1460a0a6f7c4a6d (patch)
treeed3958e1170b8671737176040d3b2c41116a1e63 /test/ruby
parent65d294ad019c8ac5bba12e2c9098360bacafc9e3 (diff)
merge revision(s) 9c94db7cfc584e982a6449b72e58a1cf25024177,fe4d906f5fbacbe6e9267af3bd3503339bad63a9: [Backport #19774]
Add tests for `return` in `BEGIN` and `END` blocks --- spec/ruby/language/return_spec.rb | 15 +++++++++++++++ test/ruby/test_syntax.rb | 1 + 2 files changed, 16 insertions(+) [Bug #19774] Fix segfault at `return` in `END` --- eval_error.c | 7 ++++++- test/ruby/test_syntax.rb | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_syntax.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index dae7807ebc..29de9b18c7 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1369,6 +1369,8 @@ eom
begin raise; ensure return; end and self
nil&defined?0--begin e=no_method_error(); return; 0;end
return puts('ignored') #=> ignored
+ BEGIN {return}
+ END {return if false}
end;
.split(/\n/).map {|s|[(line+=1), *s.split(/#=> /, 2)]}
failed = proc do |n, s|
@@ -1406,6 +1408,10 @@ eom
assert_in_out_err(['-e', 'class TestSyntax; proc{ return }.call; end'], "", [], /^-e:1:.*unexpected return \(LocalJumpError\)/)
end
+ def test_return_in_END
+ assert_normal_exit('END {return}')
+ end
+
def test_syntax_error_in_rescue
bug12613 = '[ruby-core:76531] [Bug #12613]'
assert_syntax_error("#{<<-"begin;"}\n#{<<-"end;"}", /Invalid retry/, bug12613)