test(command-test): cheap-fill M3 gap + Coverage Statements (Test-Cov Phase 2.6)
3 mutations tested. 2 caught, 1 uncaught (M3: cancel_all with 2+ simultaneous commands). Cheap-fill: added 2-unit simultaneous cancel_all scenario with both-nil assertions.
This commit is contained in:
48
README.md
Normal file
48
README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# sporel-module-lib-core.command-test
|
||||
|
||||
P.3.7 reference test-module — validates `lib-core.command` API contracts
|
||||
via the `engine.test.*` assertion surface.
|
||||
|
||||
- Module-ID: `lib-core.command-test`
|
||||
- Version: `0.1.0`
|
||||
- Kind: `test-module` (headless; runs init() once + exits)
|
||||
- Spec: `meta/docs/superpowers/specs/2026-05-14-p3-7-lib-command-design.md`
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
Sporel.exe --test-libs=lib-core.command-test
|
||||
```
|
||||
|
||||
Output is TAP version 13 on stdout; exit-code = failure-count (0 = all pass).
|
||||
|
||||
## Coverage Statements (2026-05-16 Fault-Injection Audit)
|
||||
|
||||
Verified via deliberate-mutation in fixture-mirror; mutations reverted after observation.
|
||||
|
||||
### Caught Mutations
|
||||
|
||||
| # | Mutation | Caught by |
|
||||
|---|---|---|
|
||||
| M1 | `M.move_to` prefixed with `do return end` (complete no-op) | 6 assertions fail: "current returns move-command data" (ok 4), "is_moving true after move_to" (ok 5), "update moves 10px" (ok 9), "arrival snap to target.x" (ok 11), "cancel doesn't affect h3" (ok 14), "move_to with unknown handle errors" (ok 23) |
|
||||
| M2 | `M.is_moving` prefixed with `do return false end` (always false) | Assertion "is_moving true after move_to" (ok 5) |
|
||||
|
||||
### Uncaught Mutations (Gaps)
|
||||
|
||||
| # | Mutation | Why uncaught | Severity |
|
||||
|---|---|---|---|
|
||||
| M3 | `M.cancel_all` rewritten to loop-and-break after first entry (only cancels one command) | Existing test cancels h2 manually before calling `cancel_all`, leaving only h3 active — single-entry cancel_all succeeds trivially | Medium |
|
||||
|
||||
**Resolution per Gap:**
|
||||
- Gap M3: Cheap-fill applied — added a second `cancel_all` scenario where both h2 and h3 are active simultaneously; asserts both are nil after `cancel_all` (commit see below).
|
||||
|
||||
### Cheap-Gap-Fills Applied
|
||||
|
||||
| Gap | New Assertion | Re-Inject Verifies |
|
||||
|---|---|---|
|
||||
| M3 | `cancel_all clears h2 of 2-unit batch` — `current(h2) == nil` after issuing move to both then cancel_all | ✓ |
|
||||
| M3 | `cancel_all clears h3 of 2-unit batch` — `current(h3) == nil` after same cancel_all | ✓ |
|
||||
|
||||
### Tested Production-Lib Surface
|
||||
|
||||
`lib-core.command` v0.1.0 — Tests cover: `register`, `unregister`, `count_registered`, `move_to`, `current`, `is_moving`, `cancel`, `cancel_all`, `speed`, `set_speed`, `arrive_threshold`, `set_arrive_threshold`, `enabled`, `set_enabled`, `update` (step + arrival-snap).
|
||||
6
init.lua
6
init.lua
@@ -56,7 +56,7 @@ function M.run_tests(ctx)
|
||||
T.equals(s2.x, 5, "arrival snap to target.x")
|
||||
T.assert(command.current(h2) == nil, "arrival clears active command")
|
||||
|
||||
-- Cancel + cancel_all (3)
|
||||
-- Cancel + cancel_all (5)
|
||||
s2.x, s2.y = 0, 0
|
||||
command.move_to({h2, h3}, 1000, 0)
|
||||
command.cancel(h2)
|
||||
@@ -64,6 +64,10 @@ function M.run_tests(ctx)
|
||||
T.assert(command.current(h3) ~= nil, "cancel doesn't affect h3")
|
||||
command.cancel_all()
|
||||
T.assert(command.current(h3) == nil, "cancel_all clears remaining")
|
||||
command.move_to({h2, h3}, 500, 0)
|
||||
command.cancel_all()
|
||||
T.assert(command.current(h2) == nil, "cancel_all clears h2 of 2-unit batch")
|
||||
T.assert(command.current(h3) == nil, "cancel_all clears h3 of 2-unit batch")
|
||||
|
||||
-- Speed-Setter (2)
|
||||
T.equals(command.speed(h2), 100, "speed from register")
|
||||
|
||||
Reference in New Issue
Block a user