Files
ww/test/lang/continue_test.ww
Hojun-Cho 83f5956df2 test: banner purge + WHY-only comment sweep (rule 8)
Every section banner dies (103 -> 0) across test/lang, the observer
suites, the C carriers, and the five comment-heavy corpus fixtures;
banner provenance (#N cites, carrier numbers, repair-cluster labels)
folded into headers or adjacent WHY comments. Narration deleted; row
provenance, ref cites, divergence pins, and layout contracts kept
(fwd-ref decl-order guards and bootstrap-gate corpus rationale
restored where the sweep over-cut). Comment-only proven: all 3742
wwbuild workdir .s byte-identical before/after; test-commit and
test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
2026-08-08 21:40:23 +09:00

53 lines
1.3 KiB
Plaintext

// #138: `continue` in a loop with a post-step must run the
// post-step BEFORE re-testing the cond/bound. Migrated from
// test/wcc/911_continue_run.c (value rows; cs==ww byte-id rides T2).
//
// Pre-fix the continue-target was the loop top, SKIPPING the post-step, so the
// value that triggered continue never advanced → infinite loop. Both stages
// emitted identical buggy asm, so the byte-id gate was blind; the runtime
// readback (count/sum mismatch, or a hang) is the net. The 1-clause row pins
// the no-post-step shape stays unchanged (cont-target = loop top).
package continue_test;
@test fn for3_skip_one() void = {
let count: i32 = 0;
for (let i: i32 = 0; i < 5; i += 1) {
if (i == 2) { continue; };
count += 1;
};
assert(count == 4);
};
@test fn for3_skip_two() void = {
let c: i32 = 0;
for (let i: i32 = 0; i < 5; i += 1) {
if (i == 1) { continue; };
if (i == 3) { continue; };
c += 10;
};
assert(c == 30);
};
@test fn range_skip() void = {
let xs: [5]i32 = [10, 20, 30, 40, 50];
let sum: i32 = 0;
for (let v .. xs) {
if (v == 30) { continue; };
sum += v;
};
assert(sum == 120);
};
@test fn for1_continue_byteid() void = {
let count: i32 = 0;
let i: i32 = 0;
for (i < 5) {
let cur: i32 = i;
i += 1;
if (cur == 2) { continue; };
count += 1;
};
assert(count == 4);
};