mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 18:03:40 +00:00

This adds an additional `test_result` attribute to [endlevel], intended for use with the automated unit tests. This allows for the unit tests to differentiate a pass/fail result separately from scenario victory or defeat, which allows for more accurately determining the outcome of a test as well as addresses the potential, for example, for a scenario to be expect to pass because of the {SUCCEED} macro but instead passes because the scenario ended as a victory through some other method. Additional unit tests which were the original motivation for this change are also added as part of this. They test, as much as possible, that events are executed at all, and are then also executed in the expected order.
126 lines
2.6 KiB
INI
126 lines
2.6 KiB
INI
#textdomain wesnoth
|
|
#define RETURN X
|
|
[if]
|
|
[variable]
|
|
name=ended
|
|
boolean_not_equals=yes
|
|
[/variable]
|
|
[then]
|
|
[if]
|
|
{X}
|
|
[then]
|
|
{VARIABLE ended yes}
|
|
[endlevel]
|
|
test_result=pass
|
|
linger_mode = yes
|
|
[/endlevel]
|
|
[/then]
|
|
[else]
|
|
[test_condition]
|
|
result=no
|
|
{X}
|
|
[/test_condition]
|
|
{VARIABLE ended yes}
|
|
[endlevel]
|
|
test_result=fail
|
|
linger_mode = yes
|
|
[/endlevel]
|
|
[/else]
|
|
[/if]
|
|
[/then]
|
|
[/if]
|
|
#enddef
|
|
|
|
#define ASSERT X
|
|
[if]
|
|
[variable]
|
|
name=ended
|
|
boolean_not_equals=yes
|
|
[/variable]
|
|
[then]
|
|
[if]
|
|
{X}
|
|
[else]
|
|
[test_condition]
|
|
result=no
|
|
{X}
|
|
[/test_condition]
|
|
{VARIABLE ended yes}
|
|
[endlevel]
|
|
test_result=fail
|
|
linger_mode = yes
|
|
[/endlevel]
|
|
[/else]
|
|
[/if]
|
|
[/then]
|
|
[/if]
|
|
#enddef
|
|
|
|
#define GENERIC_UNIT_TEST NAME CONTENT
|
|
#arg SIDE1_CONTROLLER
|
|
human#endarg
|
|
#arg SIDE2_CONTROLLER
|
|
human#endarg
|
|
#arg TURNS
|
|
-1#endarg
|
|
#arg SIDE1_RECRUIT
|
|
#endarg
|
|
#arg SIDE1_GOLD
|
|
100#endarg
|
|
#arg SIDE1_LEADER
|
|
Elvish Archer#endarg
|
|
|
|
[test]
|
|
name = "Unit Test " + {NAME}
|
|
map_file=test/maps/generic_unit_test.map
|
|
turns = {TURNS}
|
|
id = {NAME}
|
|
is_unit_test = yes
|
|
|
|
{DAWN}
|
|
|
|
[side]
|
|
side=1
|
|
controller={SIDE1_CONTROLLER}
|
|
recruit={SIDE1_RECRUIT}
|
|
gold={SIDE1_GOLD}
|
|
[leader]
|
|
name = "Alice"
|
|
type = {SIDE1_LEADER}
|
|
id=alice
|
|
[/leader]
|
|
[/side]
|
|
[side]
|
|
side=2
|
|
controller={SIDE2_CONTROLLER}
|
|
[leader]
|
|
name = "Bob"
|
|
type = Orcish Grunt
|
|
id=bob
|
|
[/leader]
|
|
[/side]
|
|
|
|
{CONTENT}
|
|
[/test]
|
|
#enddef
|
|
|
|
#define FAIL
|
|
{RETURN ([false][/false])}
|
|
#enddef
|
|
|
|
#define SUCCEED
|
|
{RETURN ([true][/true])}
|
|
#enddef
|
|
|
|
#define FAIL_IF_NOT FLAG NOT_EQUALS
|
|
[if]
|
|
[variable]
|
|
name={FLAG}
|
|
not_equals={NOT_EQUALS}
|
|
[/variable]
|
|
[then]
|
|
{FAIL}
|
|
[/then]
|
|
[/if]
|
|
#enddef
|