From 66ecd0cda883e60cf1384cb7136f5e615d21a06a Mon Sep 17 00:00:00 2001 From: Calic Date: Sat, 16 May 2026 02:38:30 +0200 Subject: [PATCH] test(launcher-test): cheap-fill M3 gap + Coverage Statements (Test-Cov Phase 2.7) 3 mutations tested. 2 caught, 1 uncaught (M3: unknown-state fallback returns nil). Cheap-fill: added fsm.next("garbage_state", "esc") == "garbage_state" assertion. --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ init.lua | 3 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..15291e8 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# sporel-module-lib-sporel.launcher-test + +P.3.4 reference test-module — validates `lib-sporel.launcher` FSM contracts +and engine-surface existence via the `engine.test.*` assertion surface. + +- Module-ID: `lib-sporel.launcher-test` +- Version: `0.1.0` +- Kind: `test-module` (headless; runs init() once + exits) +- Note: Embeds its own byte-identical copy of `fsm.lua` (Sporel-resolver does + not resolve module-as-dep; drift guarded by smoke.sh P0-S15-pre hash check). + +## Run + +```bash +Sporel.exe --test-libs=lib-sporel.launcher-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 the launcher-test fixture's own `fsm.lua` +copy; mutations reverted after observation. + +### Caught Mutations + +| # | Mutation | Caught by | +|---|---|---| +| M1 | `STATE_LIST + "esc"` returns `STATE_LIST` instead of `STATE_QUIT_CONFIRM` | Assertion "list+esc -> quit_confirm" (ok 1) | +| M2 | `STATE_QUIT_CONFIRM + "enter"` returns `STATE_QUIT_CONFIRM` instead of `EXIT` | Assertion "quit_confirm+enter -> exit" (ok 3) | + +### Uncaught Mutations (Gaps) + +| # | Mutation | Why uncaught | Severity | +|---|---|---|---| +| M3 | Fallback `return state` removed (unknown state returns nil) | No test calls `fsm.next` with an unrecognized state string | Low | + +**Resolution per Gap:** +- Gap M3: Cheap-fill applied — added assertion `fsm.next("garbage_state", "esc") == "garbage_state"` to verify unknown-state passthrough (commit see below). + +### Cheap-Gap-Fills Applied + +| Gap | New Assertion | Re-Inject Verifies | +|---|---|---| +| M3 | `unknown state passes through unchanged` — `fsm.next("garbage_state", "esc")` must equal `"garbage_state"` | ✓ | + +### Tested Production-Lib Surface + +`lib-sporel.launcher` v0.1.0 (FSM component) — Tests cover: all 5 explicit FSM transitions (`list+esc`, `quit_confirm+esc`, `quit_confirm+enter`, `quit_confirm+click_yes`, `quit_confirm+click_no`), stability for unhandled events (`list+click_module`), unknown-state passthrough, and engine-surface existence for `engine.module.list`, `engine.module.dir_of`, `engine.render.draw_text`, `engine.render.measure_text`. diff --git a/init.lua b/init.lua index 77d0e5a..139de80 100644 --- a/init.lua +++ b/init.lua @@ -19,8 +19,9 @@ function M.run_tests(ctx) engine.test.equals(fsm.next(fsm.STATE_QUIT_CONFIRM, "click_yes"), fsm.EXIT, "quit_confirm+click_yes -> exit") engine.test.equals(fsm.next(fsm.STATE_QUIT_CONFIRM, "click_no"), fsm.STATE_LIST, "quit_confirm+click_no -> list") - -- FSM stability (1) + -- FSM stability (2) engine.test.equals(fsm.next(fsm.STATE_LIST, "click_module"), fsm.STATE_LIST, "list+click_module -> list (switch is side-effect)") + engine.test.equals(fsm.next("garbage_state", "esc"), "garbage_state", "unknown state passes through unchanged") -- Engine-surface existence (6) engine.test.assert(type(engine.module.list) == "function", "engine.module.list is function")