Files
m3te/tests/board_init.sx
swipelab a7b41ccbca migrate to the new for-loop syntax
Drop the ':' before captures (for xs (x) / for 0..n (i)); the index
capture becomes the trailing open range (for xs, 0.. (x, i)). 136
headers across 26 files, mechanical.

Five headless tests (banner_layout, hit_test, swipe_commit,
swipe_intent, swipe_reshuffle) also gain a direct
#import "modules/ui/types.sx" — they named Point/Frame through a
transitive import, which bare visibility no longer permits.

Gates: sx build --target ios-sim main.sx links; tools/run_tests.sh
23/23.
2026-06-10 20:39:59 +03:00

40 lines
1.3 KiB
Plaintext

// Board-state golden: seed the board deterministically, dump it, and assert
// the no-pre-existing-match invariant (zero horizontal/vertical 3-in-a-rows).
// The dump is locked as a snapshot so the seeded board state can't drift.
#import "modules/std.sx";
#import "board.sx";
t :: #import "test.sx";
SEED :: 1337;
// Count every horizontal or vertical window of three consecutive same-type
// gems. A correctly initialized board has zero. This walks the finished board
// independently of the placement logic, so it's a real check, not a tautology.
count_three_runs :: (b: *Board) -> s32 {
runs : s32 = 0;
for 0..BOARD_ROWS (row) {
for 0..(BOARD_COLS - 2) (col) {
g := b.at(col, row);
if g == b.at(col + 1, row) and g == b.at(col + 2, row) { runs += 1; }
}
}
for 0..(BOARD_ROWS - 2) (row) {
for 0..BOARD_COLS (col) {
g := b.at(col, row);
if g == b.at(col, row + 1) and g == b.at(col, row + 2) { runs += 1; }
}
}
runs
}
main :: () -> s32 {
board : Board = ---;
board.init(SEED);
out(board_dump(@board));
t.expect(count_three_runs(@board) == 0, "seeded board has no 3-in-a-row runs");
print("ok: board_init no-match invariant holds\n");
return 0;
}