commit c37dd1678fbdc9c831ae10af049ab506caa8fa74 Author: Axel Meyer Date: Tue May 12 02:29:07 2026 +0200 initial(P.3.3): lib-core.input-test test-module diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3b942f8 --- /dev/null +++ b/init.lua @@ -0,0 +1,46 @@ +-- lib-core.input-test — P.3.3 test-module +-- Validates engine.input mouse surface + lib-core.input v0.3.0 BIND_MAP refactor. +-- Headless via P.3.1 test-mode pattern. 13 assertions. + +local input = require("lib-core.input") + +function init(ctx) + -- Engine surface present (5 assertions) + engine.test.assert(type(engine.input.MOUSE_LEFT) == "number", + "MOUSE_LEFT constant is integer") + engine.test.assert(type(engine.input.MOUSE_RIGHT) == "number", + "MOUSE_RIGHT constant is integer") + engine.test.assert(type(engine.input.MOUSE_MIDDLE) == "number", + "MOUSE_MIDDLE constant is integer") + engine.test.assert(type(engine.input.is_mouse_down) == "function", + "is_mouse_down function registered") + engine.test.assert(type(engine.input.was_mouse_pressed) == "function", + "was_mouse_pressed function registered") + + -- bind() accepts mouse-strings (1 assertion) + input.bind("click", {"mouse_left"}) + engine.test.equals(input.action_count(), 1, "action_count == 1 after mouse bind") + + -- bind() accepts mixed key+mouse (1 assertion) + input.bind("interact", {"e", "mouse_left"}) + engine.test.equals(input.action_count(), 2, "action_count == 2 after mixed bind") + + -- bind() rejects unknown mouse-name (atomic) (3 assertions) + local ok, err = pcall(input.bind, "bad", {"mouse_xyz"}) + engine.test.assert(not ok, "bind('bad', {'mouse_xyz'}) raises Lua error") + engine.test.assert(err and err:find("mouse_xyz", 1, true), + "error message mentions the bad string") + engine.test.equals(input.action_count(), 2, + "no partial state mutation on failed bind") + + -- is_action_down returns false in headless (no actual press) (2 assertions) + engine.test.equals(input.is_action_down("click"), false, + "headless: unpressed mouse_left is_action_down=false") + engine.test.equals(input.was_action_pressed("click"), false, + "headless: unpressed was_action_pressed=false") + + -- Existing key-only binding still works (regression-check) (1 assertion) + input.bind("walk_left", {"a", "left"}) + engine.test.equals(input.action_count(), 3, + "key-only bind still works after BIND_MAP refactor") +end diff --git a/manifest.core b/manifest.core new file mode 100644 index 0000000..cd1cd33 --- /dev/null +++ b/manifest.core @@ -0,0 +1,6 @@ +{ + "id": "lib-core.input-test.core", + "kind": "lib", + "version": "0.1.0", + "license": "Proprietary" +} diff --git a/manifest.module b/manifest.module new file mode 100644 index 0000000..e59b4fb --- /dev/null +++ b/manifest.module @@ -0,0 +1,10 @@ +{ + "id": "lib-core.input-test", + "kind": "test-module", + "version": "0.1.0", + "api": "^0.1", + "entry_point": "init.lua", + "deps": [ + {"id": "lib-core.input", "version": "0.3.0"} + ] +}