Lua tests: code coverage for applying some items
Add a new debug flag prevent_pline, which prevents all messages from going out to the UI. This prevents the tests from stopping for -more-. Add rudimentary tests for applying whistles, camera, and stethoscope.
This commit is contained in:
@@ -61,6 +61,7 @@ Set debugging flags.
|
||||
| mongen | boolean | Do monsters generate
|
||||
| hunger | boolean | Does hero's hunger-state increase
|
||||
| overwrite_stairs | boolean | Allow special-file commands overwrite the stairs
|
||||
| prevent_pline | boolean | Prevent messages going out to the UI
|
||||
|===
|
||||
|
||||
Example:
|
||||
|
||||
@@ -293,6 +293,7 @@ struct instance_flags {
|
||||
boolean debug_overwrite_stairs; /* debug: allow overwriting stairs */
|
||||
boolean debug_mongen; /* debug: prevent monster generation */
|
||||
boolean debug_hunger; /* debug: prevent hunger */
|
||||
boolean debug_prevent_pline; /* debug: prevent pline going to UI */
|
||||
boolean mon_polycontrol; /* debug: control monster polymorphs */
|
||||
boolean mon_telecontrol; /* debug: control monster teleports */
|
||||
boolean in_dumplog; /* doing the dumplog right now? */
|
||||
|
||||
@@ -1494,6 +1494,12 @@ nhl_debug_flags(lua_State *L)
|
||||
iflags.debug_overwrite_stairs = (boolean) val;
|
||||
}
|
||||
|
||||
/* prevent pline going out to the UI */
|
||||
val = get_table_boolean_opt(L, "prevent_pline", -1);
|
||||
if (val != -1) {
|
||||
iflags.debug_prevent_pline = (boolean) val;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ putmesg(const char *line)
|
||||
{
|
||||
int attr = ATR_NONE;
|
||||
|
||||
if (iflags.debug_prevent_pline)
|
||||
return;
|
||||
|
||||
if ((gp.pline_flags & URGENT_MESSAGE) != 0
|
||||
&& (windowprocs.wincap2 & WC2_URGENT_MESG) != 0)
|
||||
attr |= ATR_URGENT;
|
||||
|
||||
@@ -101,3 +101,46 @@ for i = nhc.FIRST_OBJECT, nhc.LAST_OBJECT do
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function test_use_item(action, itemname, otherkeys)
|
||||
nh.debug_flags({ prevent_pline = true });
|
||||
u.clear_inventory();
|
||||
u.giveobj(obj.new(itemname));
|
||||
local o = u.inventory;
|
||||
local ot = o:totable();
|
||||
|
||||
nh.pushkey(action);
|
||||
nh.pushkey(ot.invlet);
|
||||
|
||||
if (otherkeys ~= nil and type(otherkeys) == "string") then
|
||||
nh.pushkey(otherkeys);
|
||||
end
|
||||
|
||||
nh.doturn();
|
||||
nh.debug_flags({ prevent_pline = false });
|
||||
end
|
||||
|
||||
nh.parse_config("OPTIONS=number_pad:0");
|
||||
nh.parse_config("OPTIONS=!timed_delay");
|
||||
|
||||
-- apply
|
||||
test_use_item("a", "uncursed tin whistle");
|
||||
test_use_item("a", "cursed tin whistle");
|
||||
test_use_item("a", "blessed magic whistle");
|
||||
|
||||
test_use_item("a", "uncursed camera", "h");
|
||||
test_use_item("a", "uncursed camera", "j");
|
||||
test_use_item("a", "uncursed camera", "k");
|
||||
test_use_item("a", "blessed camera", ">");
|
||||
test_use_item("a", "+0 blessed camera", ">");
|
||||
|
||||
test_use_item("a", "blessed stethoscope", "h");
|
||||
test_use_item("a", "blessed stethoscope", "j");
|
||||
test_use_item("a", "blessed stethoscope", ".");
|
||||
test_use_item("a", "blessed stethoscope", ">");
|
||||
test_use_item("a", "blessed stethoscope", "<");
|
||||
obj.new("corpse"):placeobj(u.ux, u.uy);
|
||||
test_use_item("a", "blessed stethoscope", ">");
|
||||
obj.new("statue"):placeobj(u.ux, u.uy);
|
||||
test_use_item("a", "blessed stethoscope", ">");
|
||||
|
||||
Reference in New Issue
Block a user