end
end
+function is_map_at(x,y, mapch, lit)
+ local rm = nh.getmap(x + 1, y); -- + 1 == g.xstart
+ if rm.mapchr ~= mapch then
+ error("Terrain at (" .. x .. "," .. y .. ") is not \"" .. mapch .. "\", but \"" .. rm.mapchr .. "\"");
+ end
+ if lit ~= nil then
+ if rm.lit ~= lit then
+ error("light state at (" .. x .. "," .. y .. ") is not \"" .. lit .. "\", but \"" .. tostring(rm.lit) .. "\"");
+ end
+ end
+end
+
-- test selection parameters
function test_selection_params()
local sel = selection.new();
sel_pt_ne(seld, 6,5, 1, __func__);
end -- test_sel_match
+function test_sel_iterate()
+ local __func__ = "test_sel_iterate";
+ des.reset_level();
+ des.level_init({ style = "solidfill", fg = " " });
+
+ des.terrain(5,5, ".");
+ des.terrain(7,5, ".");
+ des.terrain(9,5, ".");
+
+ local sela = selection.match(".");
+ sela:iterate(function(x,y) des.terrain(x, y, "L"); end);
+ is_map_at(5,5, "L");
+ is_map_at(7,5, "L");
+ is_map_at(9,5, "L");
+end
+
test_selection_params();
test_sel_negate();
test_sel_logical_and();
test_sel_filter_mapchar();
test_sel_flood();
test_sel_match();
+test_sel_iterate();