mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-11-10 18:07:09 +01:00
useGame.test.tsx (494) splits by describe-block into reducer/session/debt files; handEval.test.ts (269) splits at the evaluate7 boundary; useGame.ts (268) sheds its state and reducer into gameState.ts; handFlow.ts (252) sheds its betting-state helpers into handFlowBetting.ts. useGame.ts and handFlow.ts re-export what they moved, so no importer changed. The shared test helpers live in src/test/ rather than beside the source they exercise. That is load-bearing: vite.config.ts already excludes src/test/ from coverage, so no new exclusion entry was needed. Putting them next to the source first dropped coverage to 98.57% because v8 counted the fixtures' unused branches as production code -- fixed by moving them, not by excluding them. Verified: 220 tests still pass, coverage back to 100% on statements, branches, functions and lines, and npm run build succeeds. poker-stakes violations 4 -> 0; repo total 196 -> 192. invariants.test.ts hit its 5s timeout once mid-work. It passes standalone in 2.56s and on re-run, so it is a pre-existing contention flake under parallel coverage load rather than a regression here -- noted, not papered over. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import type { Card } from '../engine/types'
|
|
|
|
/** Shared helpers for the handEval test files, split to stay under the 250-line cap. */
|
|
|
|
export const card = (rank: Card['rank'], suit: Card['suit']): Card => ({ rank, suit })
|
|
|
|
|
|
export const five = (cards: readonly Card[]): [Card, Card, Card, Card, Card] => {
|
|
if (cards.length !== 5) {
|
|
throw new Error('five: expected exactly 5 cards')
|
|
}
|
|
const [a, b, c, d, e] = cards
|
|
return [a, b, c, d, e] as [Card, Card, Card, Card, Card]
|
|
}
|
|
|
|
export const seven = (cards: readonly Card[]): [Card, Card, Card, Card, Card, Card, Card] => {
|
|
if (cards.length !== 7) {
|
|
throw new Error('seven: expected exactly 7 cards')
|
|
}
|
|
const [a, b, c, d, e, f, g] = cards
|
|
return [a, b, c, d, e, f, g] as [Card, Card, Card, Card, Card, Card, Card]
|
|
}
|
|
|
|
/** Generates all C(52,5) 5-card combinations from a 52-card deck as index tuples. */
|
|
export function* combinations5(length: number): Generator<readonly [number, number, number, number, number]> {
|
|
for (let a = 0; a < length; a += 1) {
|
|
for (let b = a + 1; b < length; b += 1) {
|
|
for (let c = b + 1; c < length; c += 1) {
|
|
for (let d = c + 1; d < length; d += 1) {
|
|
for (let e = d + 1; e < length; e += 1) {
|
|
yield [a, b, c, d, e]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|