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 without
2+# advancing the iterator. Use an int-typed array so spinel infers
3+# `int_array`.
4+arr = [10, 20, 30]
5+attempts = 0
6+for x in arr
7+ attempts += 1
8+ if x == 20 && attempts < 5
9+ redo
10+ end
11+ puts "x=#{x} attempt=#{attempts}"
12+end
13+puts "total=#{attempts}"