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 without2+
# advancing the iterator.3+
attempts = 04+
[10, 20, 30].each do |x|5+
attempts += 16+
if x == 20 && attempts < 57+
redo8+
end9+
puts "x=#{x} attempt=#{attempts}"10+
end11+
puts "total=#{attempts}"test/redo_each.rb.expectedaddedView file
Loading diff…
test/redo_each_cons.rbaddedView file
Loading diff…
test/redo_each_cons.rb.expectedaddedView file
Loading diff…
test/redo_each_slice.rbaddedView file
Loading diff…
test/redo_each_slice.rb.expectedaddedView file
Loading diff…
test/redo_each_with_index.rbaddedView file
Loading diff…
test/redo_each_with_index.rb.expectedaddedView file
Loading diff…
test/redo_each_with_object.rbaddedView file
Loading diff…
test/redo_each_with_object.rb.expectedaddedView file
Loading diff…