test(machine): rewrite State.spec.ts β drop smoke tests, strengthen withOverrodeHaltState#131
Merged
Merged
Conversation
β¦ithOverrodeHaltState
Audit findings addressed:
1. **Drop method-existence smoke tests.** Removed:
- \`'has id'\` (\`expect(...).toBeDefined()\`)
- \`'getSymbol exists'\`, \`'getCommand exists'\`, \`'getNextState exists'\`
(all \`toBeTruthy\` smoke tests)
- \`'State'\` (just \`expect(new State()).toBeTruthy()\`)
Method existence is already asserted by every test that calls these
methods or constructs a State.
2. **Drop redundant \`.toBeTruthy()\` lines next to behavior assertions.**
The constructor happy-path tests had \`expect(state).toBeTruthy()\`
followed by behavior checks β if construction failed, the next
assertion would throw anyway.
3. **Strengthen \`withOverrodeHaltState\`.** Audit-flagged: the previous
test only asserted the wrapper's name pattern. The wrapping contract
has more facets β five focused tests now pin:
- The wrapper exposes the override target on \`.overrodeHaltState\`,
and the original is left unchanged.
- The wrapper proxies \`getCommand\` and \`getNextState\` to the
original's symbolToDataMap (verifies the \`#symbolToDataMap\` share).
- The wrapper shares debugRef with the original (assignment on
either is visible from both β pins the v4 ref-share contract).
- The wrapper has its own id distinct from the original.
- The wrapper name encodes the override target (was the only
pre-rewrite check; kept).
Test count: 21 β 18 (net -3, but coverage of the actual contract is
significantly stronger). Total: 381 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task 7/10. Two audit categories: drop smoke tests, strengthen `withOverrodeHaltState`.
Smoke tests dropped
Method existence is already asserted by every test that calls these methods or constructs a State β these were nominal checks that didn't add coverage.
withOverrodeHaltState strengthening
Audit caught: the previous test only asserted the wrapper's name pattern. Five focused tests now pin the actual contract:
Numbers