test(selection-test): cheap-fill M3 gap + Coverage Statements (Test-Cov Phase 2.5)
3 mutations tested. 2 caught, 1 uncaught (M3: add unregistered-handle guard absent). Cheap-fill: added pcall assertions for add(unregistered) and toggle(unregistered).
This commit is contained in:
48
README.md
Normal file
48
README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# sporel-module-lib-core.selection-test
|
||||
|
||||
P.3.6 reference test-module — validates `lib-core.selection` API contracts
|
||||
via the `engine.test.*` assertion surface.
|
||||
|
||||
- Module-ID: `lib-core.selection-test`
|
||||
- Version: `0.1.0`
|
||||
- Kind: `test-module` (headless; runs init() once + exits)
|
||||
- Spec: `meta/docs/superpowers/specs/2026-05-14-p3-6-lib-selection-design.md`
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
Sporel.exe --test-libs=lib-core.selection-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.contains` prefixed with `do return false end` (always false) | Assertions "add → contains" (ok 6) and "toggle adds when absent" (ok 9) — 2 failures |
|
||||
| M2 | `M.count` prefixed with `do return 0 end` (always zero) | Assertion "count = 1 after add" (ok 7) — expected 1 got 0 |
|
||||
|
||||
### Uncaught Mutations (Gaps)
|
||||
|
||||
| # | Mutation | Why uncaught | Severity |
|
||||
|---|---|---|---|
|
||||
| M3 | `M.add` unregistered-handle guard removed (any handle accepted silently) | No test calls `add(unregistered_handle)` and expects an error | Medium |
|
||||
|
||||
**Resolution per Gap:**
|
||||
- Gap M3: Cheap-fill applied — two `pcall` error assertions added for `add(99999)` and `toggle(99999)` (commit see below).
|
||||
|
||||
### Cheap-Gap-Fills Applied
|
||||
|
||||
| Gap | New Assertion | Re-Inject Verifies |
|
||||
|---|---|---|
|
||||
| M3 | `add(unregistered) errors` — `pcall(function() selection.add(99999) end)` must return false | ✓ |
|
||||
| M3 | `toggle(unregistered) errors` — `pcall(function() selection.toggle(99999) end)` must return false | ✓ |
|
||||
|
||||
### Tested Production-Lib Surface
|
||||
|
||||
`lib-core.selection` v0.1.0 — Tests cover: `register`, `unregister`, `count_registered`, `is_empty`, `count`, `contains`, `add`, `remove`, `toggle`, `clear`, `drag_threshold`, `set_drag_threshold`, `drag_state`, `box_rect`, `enabled`, `set_enabled`, `set_drag_box_color`, `drag_box_color`, `set_highlight_color`, `highlight_color`.
|
||||
6
init.lua
6
init.lua
@@ -64,9 +64,13 @@ function M.run_tests(ctx)
|
||||
T.assert(hc[1]==50 and hc[2]==60 and hc[3]==70 and hc[4]==80,
|
||||
"set_highlight_color writes correctly")
|
||||
|
||||
-- Error-Handling (1)
|
||||
-- Error-Handling (3)
|
||||
local ok = pcall(function() selection.set_drag_threshold(-1) end)
|
||||
T.assert(not ok, "set_drag_threshold(-1) errors")
|
||||
local ok2 = pcall(function() selection.add(99999) end)
|
||||
T.assert(not ok2, "add(unregistered) errors")
|
||||
local ok3 = pcall(function() selection.toggle(99999) end)
|
||||
T.assert(not ok3, "toggle(unregistered) errors")
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user