Commit 7059580f
7059580fed19Merged
Ryan Seys <[email protected]> · 6 months ago · 10 files · +10 added
Description
test: cover redo in while/until/for + nested mixed-loop test
Five tests:
- redo_while.rb / redo_until.rb: counter-guarded redo, body re-runs without re-checking the loop guard.
- redo_for_range.rb / redo_for_array.rb: redo re-runs the body without advancing the loop variable.
- redo_nested.rb: outer while + inner times, exercises label-stack uniqueness across mixed loop kinds (the whole point of having the counter-driven sp_redo_ naming).
Addresses gemini-code-assist's medium-priority comment on PR matz/spinel#283 about nested-scope label-stack correctness.
🤖 Generated with Claude Code
Details
- Commit
- 7059580fed19
- Parent
- 4ed92ee63631
test/redo_for_array.rbaddedView file
1+
# RedoNode -- `redo` inside `for x in array`: re-runs body without2+
# advancing the iterator. Use an int-typed array so spinel infers3+
# `int_array`.4+
arr = [10, 20, 30]5+
attempts = 06+
for x in arr7+
attempts += 18+
if x == 20 && attempts < 59+
redo10+
end11+
puts "x=#{x} attempt=#{attempts}"12+
end13+
puts "total=#{attempts}"test/redo_for_array.rb.expectedaddedView file
Loading diff…
test/redo_for_range.rbaddedView file
Loading diff…
test/redo_for_range.rb.expectedaddedView file
Loading diff…
test/redo_nested.rbaddedView file
Loading diff…
test/redo_nested.rb.expectedaddedView file
Loading diff…
test/redo_until.rbaddedView file
Loading diff…
test/redo_until.rb.expectedaddedView file
Loading diff…
test/redo_while.rbaddedView file
Loading diff…
test/redo_while.rb.expectedaddedView file
Loading diff…