add sighted events unit tests

This commit is contained in:
Chris Beck 2014-05-16 18:09:52 -04:00
parent 9df026f8e8
commit 94fdab4389
6 changed files with 399 additions and 0 deletions

View file

@ -0,0 +1,10 @@
Gg, Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg
Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov
Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov
Gg^Kov, 1 Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Kha^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Kha^Kov, Gg^Kov, Gg^Kov, 2 Gg^Kov, Gg^Kov
Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Cha^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Cha^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov
Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov
Gg^Kov, Gg^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Gg^Kov
Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg
Gg^Kov, Gg^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Chs^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Ch^Kov, Gg^Kov, Gg
Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg^Kov, Gg, Gg^Kov, Gg, Gg^Kov, Gg^Kov, Gg^Kov, Gg, Gg

View file

@ -0,0 +1,107 @@
# This test checks that sighted events are being triggered
# at the appropriate time. An elvish archer moves towards
# and discovers an orcish grunt.
# We pass if the elvish archer is the discoverer, and the
# variable "sighted_should_trigger" is set.
# A companion test checks that we fail if we don't set that
# flag.
[test]
name = "Unit Test sighted_events"
map_data = "{test/maps/sighted_events.map}"
turns = 4
id = sighted_events
random_start_time = no
{DAWN}
[side]
side=1
controller=human
name = "Alice"
type = Elvish Archer
id=alice
fog=yes
[/side]
[side]
side=2
controller=human
name = "Bob"
type = Orcish Grunt
id=bob
fog=yes
[/side]
[event]
name = prestart
{VARIABLE sighted_should_trigger no}
[/event]
[event]
name = sighted
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
{RETURN ({VARIABLE_CONDITIONAL sighted_should_trigger boolean_equals yes})}
[/event]
#Alice moves towards Bob.
[event]
name = side 1 turn 1 refresh
[do_command]
[move]
x=1,2,3,4,5,6,7
y=3,3,3,3,3,3,3
[/move]
[/do_command]
[/event]
#Bob moves down, then up.
[event]
name = side 2 turn 1 refresh
[do_command]
[move]
x=16,16,16
y=3,4,5
[/move]
[/do_command]
[do_command]
[move]
x=16,16,16
y=5,4,3
[/move]
[/do_command]
[/event]
#Alice discovers Bob.
[event]
name = side 1 turn 2 refresh
[do_command]
[move]
x=7,8
y=3,3
[/move]
[/do_command]
#With the next stop Bob should be visible.
{VARIABLE sighted_should_trigger yes}
[do_command]
[move]
x=8,9
y=3,3
[/move]
[/do_command]
[/event]
#If we got this far without triggering sighted, we fail the test.
[event]
name = side 2 turn 2
{RETURN ([false][/false])}
[/event]
#This makes the sides pass their turns, when the other events have taken place.
[event]
name = side turn
first_time_only = no
[end_turn]
[/end_turn]
[/event]
[/test]

View file

@ -0,0 +1,103 @@
# This is a companion test to "sighted_events".
# It checks that when a certain flag is not set,
# we do indeed fail the test.
[test]
name = "Unit Test sighted_events_fail"
map_data = "{test/maps/sighted_events.map}"
turns = 4
id = sighted_events_fail
random_start_time = no
{DAWN}
[side]
side=1
controller=human
name = "Alice"
type = Elvish Archer
id=alice
fog=yes
[/side]
[side]
side=2
controller=human
name = "Bob"
type = Orcish Grunt
id=bob
fog=yes
[/side]
[event]
name = prestart
{VARIABLE sighted_should_trigger no}
[/event]
[event]
name = sighted
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
{RETURN ({VARIABLE_CONDITIONAL sighted_should_trigger boolean_equals yes})}
[/event]
#Alice moves towards Bob.
[event]
name = side 1 turn 1 refresh
[do_command]
[move]
x=1,2,3,4,5,6,7
y=3,3,3,3,3,3,3
[/move]
[/do_command]
[/event]
#Bob moves down, then up.
[event]
name = side 2 turn 1 refresh
[do_command]
[move]
x=16,16,16
y=3,4,5
[/move]
[/do_command]
[do_command]
[move]
x=16,16,16
y=5,4,3
[/move]
[/do_command]
[/event]
#Alice discovers Bob.
[event]
name = side 1 turn 2 refresh
[do_command]
[move]
x=7,8
y=3,3
[/move]
[/do_command]
#With the next stop Bob should be visible.
#{VARIABLE sighted_should_trigger yes} <-- With this line commented out the test should fail
[do_command]
[move]
x=8,9
y=3,3
[/move]
[/do_command]
[/event]
#If we got this far without triggering sighted, we fail the test.
[event]
name = side 2 turn 2
{RETURN ([false][/false])}
[/event]
#This makes the sides pass their turns, when the other events have taken place.
[event]
name = side turn
first_time_only = no
[end_turn]
[/end_turn]
[/event]
[/test]

View file

@ -0,0 +1,90 @@
# This test checks that sighted events are being triggered
# at the appropriate time. An elvish archer moves towards
# an orcish grunt, then the orcish grunt moves towards and
# is discovered by the archer, without being discovered itself.
# We pass if the elvish archer is the discoverer, and the
# variable "sighted_should_trigger" is set.
# A companion test checks that we fail if we don't set that
# flag.
[test]
name = "Unit Test sighted_on_opponents_turn"
map_data = "{test/maps/sighted_events.map}"
turns = 4
id = sighted_on_opponents_turn
random_start_time = no
{DAWN}
[side]
side=1
controller=human
name = "Alice"
type = Elvish Archer
id=alice
fog=yes
[/side]
[side]
side=2
controller=human
name = "Bob"
type = Orcish Grunt
id=bob
fog=yes
[/side]
[event]
name = prestart
{VARIABLE sighted_should_trigger no}
[/event]
[event]
name = sighted
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
{RETURN ({VARIABLE_CONDITIONAL sighted_should_trigger boolean_equals yes})}
[/event]
#Alice moves towards Bob.
[event]
name = side 1 turn 1 refresh
[do_command]
[move]
x=1,2,3,4,5,6,7
y=3,3,3,3,3,3,3
[/move]
[/do_command]
[/event]
#Bob moves to be seen by alice, but doesnt see her himself.
[event]
name = side 2 turn 1 refresh
{VARIABLE sighted_should_trigger yes}
[do_command]
[move]
x=16,15,14
y=3,3,3
[/move]
[/do_command]
[do_command]
[move]
x=14,15,16
y=3,3,3
[/move]
[/do_command]
[/event]
#If we got this far without triggering sighted, we fail the test.
[event]
name = side 1 turn 2
{RETURN ([false][/false])}
[/event]
#This makes the sides pass their turns, when the other events have taken place.
[event]
name = side turn
first_time_only = no
[end_turn]
[/end_turn]
[/event]
[/test]

View file

@ -0,0 +1,85 @@
# This is a companion test to "sighted_on_opponents_turn".
# It checks that when a certain flag is not set,
# we do indeed fail the test.
[test]
name = "Unit Test sighted_on_opponents_turn_fail"
map_data = "{test/maps/sighted_events.map}"
turns = 4
id = sighted_on_opponents_turn_fail
random_start_time = no
{DAWN}
[side]
side=1
controller=human
name = "Alice"
type = Elvish Archer
id=alice
fog=yes
[/side]
[side]
side=2
controller=human
name = "Bob"
type = Orcish Grunt
id=bob
fog=yes
[/side]
[event]
name = prestart
{VARIABLE sighted_should_trigger no}
[/event]
[event]
name = sighted
{ASSERT ({VARIABLE_CONDITIONAL unit.id equals bob})}
{ASSERT ({VARIABLE_CONDITIONAL second_unit.id equals alice})}
{RETURN ({VARIABLE_CONDITIONAL sighted_should_trigger boolean_equals yes})}
[/event]
#Alice moves towards Bob.
[event]
name = side 1 turn 1 refresh
[do_command]
[move]
x=1,2,3,4,5,6,7
y=3,3,3,3,3,3,3
[/move]
[/do_command]
[/event]
#Bob moves to be seen by alice, but doesnt see her himself.
[event]
name = side 2 turn 1 refresh
#{VARIABLE sighted_should_trigger yes} <-- With this line commented the test should fail.
[do_command]
[move]
x=16,15,14
y=3,3,3
[/move]
[/do_command]
[do_command]
[move]
x=14,15,16
y=3,3,3
[/move]
[/do_command]
[/event]
#If we got this far without triggering sighted, we fail the test.
[event]
name = side 1 turn 2
{RETURN ([false][/false])}
[/event]
#This makes the sides pass their turns, when the other events have taken place.
[event]
name = side turn
first_time_only = no
[end_turn]
[/end_turn]
[/event]
[/test]

View file

@ -18,6 +18,10 @@
0 order_of_nested_events
0 unit_spawns_at_nearest_vacant_hex
0 units_offmap_goto_recall
0 sighted_events
1 sighted_events_fail
0 sighted_on_opponents_turn
1 sighted_on_opponents_turn_fail
#
# Attack calculations tests
#