Skip to content

test(engine): coverage script and floors for the rules engine - #271

Merged
arrzdev merged 2 commits into
mainfrom
test/engine-coverage
Nov 2, 2026
Merged

arrzdev merged 2 commits into
mainfrom
test/engine-coverage

Conversation

@arrzdev

@arrzdev arrzdev commented Nov 2, 2026

Copy link
Copy Markdown
Owner

What

packages/abalone-engine holds every rule of the game but had no coverage report and no floor. This adds a test:coverage script (v8), tests for the branches the report showed as uncovered, and thresholds at today's numbers rounded down.

The CI gate already runs test:coverage instead of test for any package that defines it (.github/actions/gate/action.yml), so the workflow itself needs no change.

Coverage

Before After Floor
Lines 99.29% (422/425) 99.29% (422/425) 99
Branches 94.75% (253/267) 98.12% (262/267) 98
Statements 98.69% (529/536) 99.25% (532/536) 99
Functions 100% 100% 100

moves.ts and rules.ts now reach 100% on every metric. New tests cover:

  • destinationsFor: a line read toward a lower row gives the same squares in the same order as the same line read the other way.
  • selectMarble: a white lead marble grows a white line and starts over on black.
  • selectRun: a walk that runs off the board before it reaches its target gives up.
  • goToMove: hand-edited history entries (no marbles, a destination that touches none, no shovedMarbles) still restore, just without the highlight.
  • isValidSelection and undoTargetIndex: a bot game with no recorded colour behaves as if the human plays black.

None of the new tests found a rules bug.

What's still uncovered:

  • game-state.ts:260: unreachable, since directionBetween already returned non-null for the anchor in the line above. Removing it would be a refactor, which is out of scope here.
  • board-setups.ts and position.ts: setup-table helpers, not rules. They're left for a follow-up.

Verify

pnpm --filter @repo/abalone-engine test:coverage
pnpm typecheck && pnpm biome:check && pnpm exec turbo run build --filter=@repo/game...

Reads a line across the rows from either end, grows a white selection,
gives up on a run that leaves the board, restores hand-edited history
entries and falls back to black when a bot game has no colour.
The CI gate runs test:coverage for any package that has it, so the
engine's floors (lines 99, branches 98, functions 100, statements 99)
now gate every merge.

@arrzdev arrzdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Test-only change: the engine suite runs under coverage in the gate (CI log: 106 passed, branches 98.12%, all files over the floors), and the coverage-v8 version matches the one apps/game already uses. The two remaining gaps listed in the description are fine as follow-ups.

@arrzdev
arrzdev merged commit 0fb827d into main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant