add a wml unit test for {CLEAR_VARIABLE} macro
This commit is contained in:
parent
c762937e74
commit
a273be5520
2 changed files with 60 additions and 0 deletions
58
data/test/scenarios/test_clear.cfg
Normal file
58
data/test/scenarios/test_clear.cfg
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Test that clearing multiple variables works, also that
|
||||
# the WML `_G` analogue works.
|
||||
|
||||
{GENERIC_UNIT_TEST "test_clear_one" (
|
||||
[event]
|
||||
name = start
|
||||
|
||||
{VARIABLE A 5}
|
||||
{VARIABLE B 10}
|
||||
|
||||
{CLEAR_VARIABLE A}
|
||||
|
||||
[lua]
|
||||
code = << local a,b,c = false,false,false
|
||||
for k,v in pairs(wesnoth.get_all_vars()) do
|
||||
if k == "A" then
|
||||
a = true
|
||||
elseif (k == "B") and (v == 10) then
|
||||
b = true
|
||||
elseif (k == "C") then
|
||||
c = true
|
||||
end
|
||||
end
|
||||
wesnoth.set_variable("result", (not a) and b and (not c)) >>
|
||||
[/lua]
|
||||
|
||||
{RETURN {VARIABLE_CONDITIONAL result boolean_equals true}}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
{GENERIC_UNIT_TEST "test_clear_two" (
|
||||
[event]
|
||||
name = start
|
||||
|
||||
{VARIABLE A 5}
|
||||
{VARIABLE B 10}
|
||||
{VARIABLE C 20}
|
||||
|
||||
{CLEAR_VARIABLE A,C}
|
||||
|
||||
[lua]
|
||||
code = << local a,b,c = false,false,false
|
||||
for k,v in pairs(wesnoth.get_all_vars()) do
|
||||
if k == "A" then
|
||||
a = true
|
||||
elseif (k == "B") and (v == 10) then
|
||||
b = true
|
||||
elseif (k == "C") then
|
||||
c = true
|
||||
end
|
||||
end
|
||||
wesnoth.set_variable("result", (not a) and b and (not c)) >>
|
||||
[/lua]
|
||||
|
||||
{RETURN {VARIABLE_CONDITIONAL result boolean_equals true}}
|
||||
[/event]
|
||||
)}
|
||||
|
|
@ -43,6 +43,8 @@
|
|||
0 two_plus_two
|
||||
1 two_plus_two_fail
|
||||
0 order_of_nested_events
|
||||
0 test_clear_one
|
||||
0 test_clear_two
|
||||
0 test_unit_map
|
||||
0 unit_spawns_at_nearest_vacant_hex
|
||||
0 units_offmap_goto_recall
|
||||
|
|
Loading…
Add table
Reference in a new issue