Commit c3af7ad7

c3af7ad7d5f9Merged

Ryan Seys <[email protected]> · 6 months ago · 10 files · +10 added

Description

test: cover redo in the each-family blocks

Five tests exercising the each-family wrappings: Array#each (int_array branch), Array#each_with_index, Array#each_slice (verifies redo re-runs with the same slice array), Array#each_cons, and Array#each_with_object.

The each_with_object test notes the goto-style redo semantics: mutations to the accumulator BEFORE the redo persist into the re-run, so the test pattern only mutates after the redo guard to keep the result deterministic.

🤖 Generated with Claude Code

Details

Commit
c3af7ad7d5f9
Parent
c2c9583c5309

test/redo_each.rbaddedView file

1+# RedoNode -- `redo` inside Array#each: re-runs body without
2+# advancing the iterator.
3+attempts = 0
4+[10, 20, 30].each do |x|
5+ attempts += 1
6+ if x == 20 && attempts < 5
7+ redo
8+ end
9+ puts "x=#{x} attempt=#{attempts}"
10+end
11+puts "total=#{attempts}"