Mechanical sweep of all .sx sources, plan docs, and tests/expected snapshots for the sx language rename (s8/s16/s32/s64 -> i8/i16/i32/i64). Verified: tools/run_tests.sh 23/23. Note: the ios-sim build has 2 pre-existing 'restart' dot-call errors from the sx opt-in UFCS change (sx a47ea14) — independent of this rename (present pre-sweep); migrated in the follow-up commit.
40 lines
1.3 KiB
Plaintext
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) -> i32 {
|
|
runs : i32 = 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 :: () -> i32 {
|
|
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;
|
|
}
|