Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the master version of PR #237, with unit tests.
- Loading branch information
Showing
4 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# This test scenario checks unit filter [filter_vision], | ||
# and terrain_filter [filter_vision]. It tests what happens | ||
# when there is a single, there are multiple, or there are | ||
# no matches to the standard side filter contained. | ||
|
||
#define TEST_FILTER_VISION_SCEN ID EVENTS | ||
[test] | ||
name = "Unit Test {ID}" | ||
map_data = "{test/maps/move_skip_sighted.map}" | ||
turns = 3 | ||
id = {ID} | ||
random_start_time = no | ||
|
||
{DAWN} | ||
|
||
[side] | ||
side=1 | ||
controller=human | ||
name = "Alice" | ||
type = Elvish Archer | ||
id=alice | ||
fog=yes | ||
team_name=West | ||
[/side] | ||
[side] | ||
side=2 | ||
controller=human | ||
name = "Bob" | ||
type = Orcish Grunt | ||
id=bob | ||
fog=yes | ||
team_name=East | ||
[/side] | ||
[side] | ||
side=3 | ||
controller=human | ||
name = "Dave" | ||
type = Dwarvish Fighter | ||
id=dave | ||
fog=yes | ||
team_name=East | ||
[/side] | ||
[side] | ||
side=4 | ||
controller=human | ||
name = "Charlie" | ||
type = Chocobone | ||
id=charlie | ||
fog=yes | ||
team_name=West | ||
[/side] | ||
|
||
{EVENTS} | ||
[/test] | ||
#enddef | ||
|
||
#define chat_if X | ||
{VARIABLE_OP chat_ctr add 1} | ||
|
||
[if] | ||
{X} | ||
[then] | ||
[chat] | ||
message="$chat_ctr" ": yes" | ||
[/chat] | ||
[/then] | ||
[else] | ||
[chat] | ||
message="$chat_ctr" ": no" | ||
[/chat] | ||
[/else] | ||
[/if] | ||
#enddef | ||
|
||
#define test_vision_chat X Y | ||
{chat_if ([have_unit] | ||
{X} | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/have_unit] | ||
)} | ||
{chat_if ([have_unit] | ||
{X} | ||
[filter_location] | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/filter_location] | ||
[/have_unit] | ||
)} | ||
[delay] | ||
time=500 | ||
[/delay] | ||
#enddef | ||
|
||
#define assert_test_true X Y | ||
{ASSERT ([have_unit] | ||
{X} | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/have_unit] | ||
)} | ||
{ASSERT ([have_unit] | ||
{X} | ||
[filter_location] | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/filter_location] | ||
[/have_unit] | ||
)} | ||
#enddef | ||
|
||
#define assert_test_false X Y | ||
{ASSERT ([not] | ||
[have_unit] | ||
{X} | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/have_unit] | ||
[/not] | ||
)} | ||
{ASSERT ([not] | ||
[have_unit] | ||
{X} | ||
[filter_location] | ||
[filter_vision] | ||
{Y} | ||
[/filter_vision] | ||
[/filter_location] | ||
[/have_unit] | ||
[/not] | ||
)} | ||
#enddef | ||
|
||
{TEST_FILTER_VISION_SCEN "filter_vision" ( | ||
[event] | ||
name=start | ||
{VARIABLE chat_ctr 0} | ||
|
||
{assert_test_true () (side=1,2,3,4)} | ||
{assert_test_true (side=2) (side=1,2,3,4)} | ||
{assert_test_true (side=4) (side=1,2,3,4)} | ||
{assert_test_true (side=1) (side=4)} | ||
{assert_test_true (side=2) (side=4)} | ||
{assert_test_true (side=3) (side=4)} | ||
{assert_test_true (side=4) (side=1)} | ||
{assert_test_true (side=4) (side=3)} | ||
{assert_test_false (side=4) (side=2)} | ||
{assert_test_false () (side=5)} | ||
|
||
{RETURN ([true][/true])} | ||
[/event] | ||
)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters