Skip to content

test: pin counts in examples.spec.ts (README example traces)#133

Merged
mellonis merged 1 commit into
masterfrom
test/pin-counts-examples
May 9, 2026
Merged

test: pin counts in examples.spec.ts (README example traces)#133
mellonis merged 1 commit into
masterfrom
test/pin-counts-examples

Conversation

@mellonis
Copy link
Copy Markdown
Owner

@mellonis mellonis commented May 9, 2026

Task 9/10. The README example traces are deterministic on a 2-visit fixture; the audit flagged the `> 0` weakness across this file.

What this commit pins

Constants at the top make the trajectory explicit:

  • `VISIT_COUNT = 2` (visits 1=A, 2=B-then-halt)
  • `A_VISIT_COUNT = 1` (only visit 1 has head 'A')
  • `HALT_TRANSITION_COUNT = 1` (only visit 2 transitions to halt)

Then every `> 0` becomes a pinned count:

  • `breakCount > 0` β†’ `.toBe(VISIT_COUNT)` for wildcard before-pause.
  • `symASeen > 0` β†’ `.toBe(A_VISIT_COUNT)` + non-match count = 0.
  • `order.toContain('before') / 'after'` β†’ `.toEqual(['before', 'after'])` (pins ORDER and that only the matching visit dispatches).
  • `haltPause === true` β†’ `.toHaveLength(HALT_TRANSITION_COUNT)` + visit-index pin (lifecycle-aware).
  • `stepCount > 0` / `breakCount > 0` β†’ both `.toBe(VISIT_COUNT)` in the independence test.
  • `'Disable later by assigning null'` strengthened with intermediate `debug.before === true` assertion.

Numbers

  • Test count: 7 β†’ 8.
  • Total: 392 tests pass.
  • Coverage: unchanged.

The README example traces are deterministic β€” the audit flagged the
\`> 0\` weakness in this file. Each run on the 2-visit fixture has
exact known dispatch counts.

Constants:
- VISIT_COUNT = 2 (visits 1=A, 2=B-then-halt)
- A_VISIT_COUNT = 1 (only visit 1 has head 'A')
- HALT_TRANSITION_COUNT = 1 (only visit 2 transitions to halt)

Replaced:
- \`breakCount > 0\` β†’ \`.toBe(VISIT_COUNT)\` for wildcard before-pause.
- \`symASeen > 0\` β†’ \`.toBe(A_VISIT_COUNT)\` for symbol-list match;
  also pin the non-match count (= 0) so misses on the wrong visit
  are caught.
- \`order.toContain('before') / 'after'\` β†’ \`.toEqual(['before', 'after'])\`
  for the symbol-list both-flags test (pins both ORDER and that only
  the matching visit dispatches).
- \`haltPause === true\` β†’ \`.toHaveLength(HALT_TRANSITION_COUNT)\` plus
  pin which visit triggered (lifecycle-aware index check).
- \`stepCount > 0\` / \`breakCount > 0\` β†’ \`.toBe(VISIT_COUNT)\` for both
  in the onStep+onPause-independence test.
- \`'Disable later by assigning null'\` strengthened with intermediate
  \`debug.before === true\` assertion.

Test count: 7 β†’ 8. Total: 392 tests pass.
@mellonis mellonis merged commit b6d50ad into master May 9, 2026
5 checks passed
@mellonis mellonis deleted the test/pin-counts-examples branch May 9, 2026 18:17
@github-project-automation github-project-automation Bot moved this from Todo to Done in @mellonis's machines May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant