Commit 57409b7d
57409b7d3815Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 10 files · +2 added · -8 deleted
Description
test: collapse 4 index_* tests into one index_write.rb
Indexed-slot compound writes (a[i] OP= v, a[i] &&= v,
a[i] ||= v, a[i], b[j] = ...). Four parallel tests; merged.
The op_assign section's class Vec is unique. Locals reused
across the originals (xs, counts, etc.) get per-section
prefixes (xs_aw / xs_t, counts_op / counts_aw / counts_or
/ counts_t) so spinel's local-type inference doesn't unify them
and so the merged script's accumulated state doesn't carry hash
content across sections.
4 .rb → 1. ~5s saved on Windows test step at the ~1.2s/test rate.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 57409b7d3815
- Parent
- ab028d866ed6
test/index_and_write.rbdeleted
# IndexAndWriteNode -- `a[i] &&= val`.## Reads `a[i]`; if truthy, sets a[i] = val. Mirror of IndexOrWriteNode# with condition inverted. Same temp pattern keeps receiver and# index evaluated exactly once.# Int array with non-zero slots: avoid the C-truthy vs Ruby-truthy# divergence by sticking to non-zero values that are truthy in both.xs = [1, 2, 3, 4, 5]xs[0] &&= 10 # truthy -> firesxs[2] &&= 30 # truthy -> firesxs[4] &&= xs[4] * 100 # truthy -> fires; receiver/index evaluated onceputs xs[0] # 10puts xs[1] # 2 (untouched)puts xs[2] # 30puts xs[3] # 4 (untouched)puts xs[4] # 500# Hash with int values: each set value is non-zero, so &&= behaves# the same in C and Ruby for these slots.counts = {"alice" => 30, "bob" => 25}counts["alice"] &&= 31 # truthy -> firescounts["carol"] &&= 50 # never-set (sp_StrIntHash_get returns 0) -> doesn't fireputs counts["alice"] # 31puts counts["bob"] # 25 (untouched)puts counts.length # 2 (carol not added)test/index_and_write.rb.expecteddeleted
Loading diff…
test/index_op_assign.rbdeleted
Loading diff…
test/index_op_assign.rb.expecteddeleted
Loading diff…
test/index_or_write.rbdeleted
Loading diff…
test/index_or_write.rb.expecteddeleted
Loading diff…
test/index_target.rbdeleted
Loading diff…
test/index_target.rb.expecteddeleted
Loading diff…
test/index_write.rbaddedView file
Loading diff…
test/index_write.rb.expectedaddedView file
Loading diff…