Skip to content

test: strengthen weak assertions in test suite #116#117

Merged
edloidas merged 1 commit into
masterfrom
issue-116
May 10, 2026
Merged

test: strengthen weak assertions in test suite #116#117
edloidas merged 1 commit into
masterfrom
issue-116

Conversation

@edloidas
Copy link
Copy Markdown
Owner

Audited the test suite for assertions weak enough to let real regressions pass and tightened the worst offenders. Test-only changes — no production code touched.

  • SeededRNG float / NaN / Infinity seed tests now assert documented uint32 coercion (SeededRNG(42.999) matches SeededRNG(42); NaN and Infinity match 0) instead of only same-seed reproducibility.
  • nextInt(min === max) test asserts the trivial-range early-return does not advance RNG state; inverted-bounds test asserts nextInt(10, 1) produces the same sequence as nextInt(1, 10).
  • invalid maxDice falls back to default rolls DEFAULT_MAX_DICE+1 dice and asserts the error message references DEFAULT_MAX_DICE — proves the fallback used the documented default and not Infinity, 0, or any other value.
  • max(1d20+5 vs 20, 0) versus-propagation test asserts DegreeOfSuccess.Failure instead of toBeDefined().
  • CLI --verbose test asserts the exact deterministic seeded output (4d6[3, 6, 3, (3)] = 12) instead of three loose toContain checks.
  • Two MockRNG exhaustion tests use expect.unreachable(...) instead of expect(true).toBe(false) for diagnostic failure messages.

Closes #116

Drafted with AI assistance

Strengthened `SeededRNG` normalization tests to verify documented uint32 coercion: float seed `42.999` matches `42`, `NaN` and `Infinity` seeds match `0`.
Verified `nextInt(min === max)` does not advance RNG state and inverted bounds `nextInt(10, 1)` produces the same sequence as `nextInt(1, 10)`.
Replaced `.not.toThrow()` in `invalid maxDice falls back to default` with a positive check that `DEFAULT_MAX_DICE+1` dice throws referencing `DEFAULT_MAX_DICE`.
Replaced `result.degree.toBeDefined()` with `toBe(DegreeOfSuccess.Failure)` in the `max(1d20+5 vs 20, 0)` versus propagation test.
Replaced three loose `toContain` checks in the CLI `--verbose` test with exact-match against the deterministic seeded output.
Replaced `expect(true).toBe(false)` with `expect.unreachable(...)` in two `MockRNG` exhaustion tests.
@edloidas edloidas self-assigned this May 10, 2026
@edloidas edloidas merged commit b55ae3c into master May 10, 2026
10 checks passed
@edloidas edloidas deleted the issue-116 branch May 10, 2026 11:31
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.

test: strengthen weak assertions in test suite

1 participant