summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2024-01-18 15:11:17 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2024-01-19 09:35:36 -0800
commitefe4b8ac0f5de49dcb20806f5a6c2d90273e8d52 (patch)
tree445ebb2cd10871d894f644d97d3a4df836a992fc /test/ruby
parent200d3cc14d4c98bfee3826bda9c0e09a1113d939 (diff)
Fix ensure code when running break in a while loop
We need to run ensure code when breaking from a while loop Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: Kevin Newton <kddnewton@gmail.com>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index 0765a946a5..e1bd5cfb69 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -961,6 +961,20 @@ module Prism
assert_prism_eval("[true].map { break }")
end
+ def test_break_runs_ensure
+ assert_prism_eval(<<-CODE)
+a = []
+while true
+ begin
+ break
+ ensure
+ a << 1
+ end
+end
+a
+ CODE
+ end
+
def test_EnsureNode
assert_prism_eval("begin; 1; ensure; 2; end")
assert_prism_eval("begin; 1; begin; 3; ensure; 4; end; ensure; 2; end")