# lib-core.command-test Test-lib for `lib-core.command` (Tests-as-Libs per ADR-0037). **Version:** 0.1.0 **Lib-ID:** lib-core.command-test **Requires:** lib-core.command v>=0.1.0, lib-core.input v>=0.4.0, lib-core.camera v>=0.3.0 **Tags:** test, command ## Topology ```mermaid graph LR this["lib-core.command-test"] lib_core_command["lib-core.command"] this --> lib_core_command lib_core_input["lib-core.input"] this --> lib_core_input lib_core_camera["lib-core.camera"] this --> lib_core_camera ``` ## Coverage Statement Per Fault-Injection-Audit-Convention (2026-05-16): | Section | Assertion-Count | Coverage | |---|---|---| | Register / Unregister | 3 | `register` handle, `count_registered` after register/unregister | | Move-Issue + State-Query | 3 | `move_to`, `current` returns move-data, `is_moving` true after issue, false for idle | | State-Query (idle) | 2 | `current` returns nil for idle, `is_moving` false for unknown handle | | Update-step | 2 | `update` moves 10px in 0.1s @ 100 px/s, y unchanged for horizontal move | | Arrival-snap | 2 | Snap to target.x when step >= dist, `current` cleared after arrival | | Cancel + cancel_all | 5 | `cancel(h2)` clears h2 only, `cancel_all` clears remaining; cancel_all clears 2-unit batch | | Speed-Setter | 2 | `speed` from register, `set_speed` updates | | Arrive-Threshold + Enabled | 3 | Default threshold = 2, `set_arrive_threshold` writes, `enabled` toggle | | Error-Handling | 2 | `register` with non-function errors, `move_to` with unknown handle errors | | **TOTAL** | **24** | | ### Tested-Surface - `command.register`, `command.unregister`, `command.count_registered` - `command.move_to`, `command.current`, `command.is_moving` - `command.cancel`, `command.cancel_all` - `command.speed`, `command.set_speed` - `command.arrive_threshold`, `command.set_arrive_threshold` - `command.enabled`, `command.set_enabled` - `command.update` (step + arrival-snap) ### Fault-Injection Audit (2026-05-16) 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`, `is_moving true after move_to`, `update moves 10px`, `arrival snap to target.x`, `cancel doesn't affect h3`, `move_to with unknown handle errors` | | M2 | `M.is_moving` prefixed with `do return false end` (always false) | `is_moving true after move_to` fails | #### Uncaught Mutations (Gaps) — Cheap-Fill Applied | # | Original Gap | Fill | Re-Inject Verifies | |---|---|---|---| | M3 | `M.cancel_all` rewritten to break after first entry | Added 2-unit batch scenario; asserts h2 + h3 both nil after `cancel_all` | ✓ | ### Structurally Untestable - None identified at headless level — entire surface exercisable via mocked-unit closure-state helper. ### Deferred - Multi-frame integration with `lib-core.player_control` consumer flow (covered indirectly by player_control-test). ## Running Via `--test-libs=lib-core.command-test` (Smoke P0-S-batch Stage): ```bash Sporel.exe --libs-dir= --test-libs=lib-core.command-test ``` Output is TAP version 13 on stdout; exit-code = failure-count (0 = all pass). ## References - ADR-0037 (Tests-as-Libs Convention) - ADR-0038 (API-Doc-Convention) - Production-Lib: `~/Projects/Sporel/sporel-libs/lib-core/command/README.md` - Spec: `meta/docs/superpowers/specs/2026-05-14-p3-7-lib-command-design.md`