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