From b68b1d4fbae4da7bb13252dc477615baab551ef6 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Mon, 1 Jun 2026 21:51:01 +0200 Subject: [PATCH] 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) --- init.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/init.lua b/init.lua index 519698a..d24a44d 100644 --- a/init.lua +++ b/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