initial(P.3.3): lib-core.input-test test-module
This commit is contained in:
46
init.lua
Normal file
46
init.lua
Normal file
@@ -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
|
||||||
6
manifest.core
Normal file
6
manifest.core
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"id": "lib-core.input-test.core",
|
||||||
|
"kind": "lib",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"license": "Proprietary"
|
||||||
|
}
|
||||||
10
manifest.module
Normal file
10
manifest.module
Normal file
@@ -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"}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user