test(maps): maps_t1 cell-tile material round-trip + guards
Exercises set_cell_material / get_cell_material round-trip on the write_test fixture, plus bounds rejection and unknown-layer rejection. Confirms the new public API is wired and the guards match the existing v3 write-API conventions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
31
init.lua
31
init.lua
@@ -357,6 +357,37 @@ function M.run_tests(ctx)
|
||||
-- Cleanup
|
||||
os.remove(out_path); os.remove(out_path_2); os.remove(abs_rl_path)
|
||||
|
||||
-- =====================================================================
|
||||
-- 0.5.7: Cell-Tile material API tests (maps_t1)
|
||||
-- =====================================================================
|
||||
-- Reload the write_test map for a clean slate.
|
||||
maps.set_current("write_test")
|
||||
|
||||
-- maps_t1: round-trip set/get
|
||||
maps.set_cell_material("surface", 1, 1, true)
|
||||
engine.test.equals(maps.get_cell_material("surface", 1, 1), true,
|
||||
"maps_t1: set_cell_material then get_cell_material round-trips")
|
||||
|
||||
maps.set_cell_material("surface", 1, 1, false)
|
||||
engine.test.equals(maps.get_cell_material("surface", 1, 1), false,
|
||||
"maps_t1: set_cell_material(false) clears the flag")
|
||||
|
||||
-- Out-of-bounds rejection
|
||||
local ok_oob, err_oob = pcall(function()
|
||||
maps.set_cell_material("surface", -1, 0, true)
|
||||
end)
|
||||
engine.test.assert(not ok_oob,
|
||||
"maps_t1: set_cell_material rejects negative x")
|
||||
engine.test.assert(err_oob and err_oob:find("bounds"),
|
||||
"maps_t1: bounds-error mentions 'bounds'")
|
||||
|
||||
-- Unknown-layer rejection
|
||||
local ok_lay = pcall(function()
|
||||
maps.set_cell_material("bogus_layer", 0, 0, true)
|
||||
end)
|
||||
engine.test.assert(not ok_lay,
|
||||
"maps_t1: set_cell_material rejects unknown layer")
|
||||
|
||||
engine.exit(engine.test.failures())
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user