summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-01-26 12:17:04 -0500
committerKevin Newton <kddnewton@gmail.com>2024-01-26 16:07:24 -0500
commita12052902088caff04eca2f61a4b62c0c309ba08 (patch)
tree90516a7be0d092f620cb3a3eb6b1ab7001d43ed2 /test/ruby
parent59bb78ebd023d42c9ac604c89d0885cef1622c21 (diff)
[PRISM] Fix loop in rescue blocks
Fixes ruby/prism#2250. Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index 05e95e8b06..ff0a252b71 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -987,10 +987,38 @@ module Prism
def test_UntilNode
assert_prism_eval("a = 0; until a == 1; a = a + 1; end")
+
+ # Test UntilNode in rescue
+ assert_prism_eval(<<~RUBY)
+ o = Object.new
+ o.instance_variable_set(:@ret, [])
+ def o.foo = @ret << @ret.length
+ def o.bar = @ret.length > 3
+ begin
+ raise
+ rescue
+ o.foo until o.bar
+ end
+ o.instance_variable_get(:@ret)
+ RUBY
end
def test_WhileNode
assert_prism_eval("a = 0; while a != 1; a = a + 1; end")
+
+ # Test WhileNode in rescue
+ assert_prism_eval(<<~RUBY)
+ o = Object.new
+ o.instance_variable_set(:@ret, [])
+ def o.foo = @ret << @ret.length
+ def o.bar = @ret.length < 3
+ begin
+ raise
+ rescue
+ o.foo while o.bar
+ end
+ o.instance_variable_get(:@ret)
+ RUBY
end
def test_ForNode