Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
these test will be determine what value by default of [drains] checked when no specified
  • Loading branch information
newfrenchy83 committed Sep 29, 2023
1 parent ff5c916 commit 9f4daef
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,134 @@
)}

#undef FILTER_ABILITY_TEST

#define FILTER_ABILITY_TEST_WITHOUT_VALUE
[event]
name=start
# Make sure the attacks hit
{FORCE_CHANCE_TO_HIT (id=bob) (id=alice) 100 ()}
{FORCE_CHANCE_TO_HIT (id=alice) (id=bob) 100 ()}
[modify_unit]
[filter]
[/filter]
# Make sure they don't die during the attacks
[status]
invulnerable=yes
[/status]
[/modify_unit]
[object]
silent=yes
[effect]
apply_to=new_ability
[abilities]
[drains]
[filter]
[filter_location]
time_of_day=neutral
[/filter_location]
[/filter]
[/drains]
[/abilities]
[/effect]
[filter]
id=alice
[/filter]
[/object]
{VARIABLE triggers 0}
[/event]

[event]
name=side 1 turn 1
[do_command]
[move]
x=7,13
y=3,4
[/move]
[attack]
[source]
x,y=13,4
[/source]
[destination]
x,y=13,3
[/destination]
[/attack]
[/do_command]
[end_turn][/end_turn]
[/event]

[event]
name=side 2 turn
[do_command]
[attack]
[source]
x,y=13,3
[/source]
[destination]
x,y=13,4
[/destination]
[/attack]
[/do_command]
[end_turn][/end_turn]
[/event]
#enddef

#####
# API(s) being tested: [event][filter][filter_ability]default_value
##
# Actions:
# Use the common setup from FILTER_ABILITY_TEST_WITHOUT_VALUE.
# Add an event with a filter matching Alice's drains ability.
# Alice attacks Bob and then Bob attacks Alice, as defined in FILTER_ABILITY_TEST.
##
# Expected end state:
# The filtered event is triggered exactly once.
#####
{GENERIC_UNIT_TEST event_test_filter_ability_without_value (
{FILTER_ABILITY_TEST_WITHOUT_VALUE}
[event]
name=attack
[filter]
[filter_ability]
tag_name=drains
value=10-45
[/filter_ability]
[/filter]
{ASSERT ({VARIABLE_CONDITIONAL side_number equals 1})}
{VARIABLE_OP triggers add 1}
[/event]
[event]
name=turn 2
{RETURN ({VARIABLE_CONDITIONAL triggers equals 1})}
[/event]
)}

#####
# API(s) being tested: [event][filter][filter_ability]
##
# Actions:
# Use the common setup from FILTER_ABILITY_TEST_WITHOUT_VALUE.
# Add an event with a filter for a drains ability, but without different value.
# Alice attacks Bob and then Bob attacks Alice, as defined in FILTER_ABILITY_TEST_WITHOUT_VALUE.
##
# Expected end state:
# The filtered event is never triggered.
#####
{GENERIC_UNIT_TEST event_test_filter_ability_no_match_different_value (
{FILTER_ABILITY_TEST_WITHOUT_VALUE}
[event]
name=attack
[filter]
[filter_ability]
tag_name=drains
value=33
[/filter_ability]
[/filter]
{FAIL}
[/event]
[event]
name=turn 2
{SUCCEED}
[/event]
)}

#undef FILTER_ABILITY_TEST_WITHOUT_VALUE
2 changes: 2 additions & 0 deletions wml_test_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
0 event_test_filter_ability_no_match_neg_prefix
0 event_test_filter_ability_active
0 event_test_filter_ability_active_inactive
0 event_test_filter_ability_without_value
0 event_test_filter_ability_no_match_different_value
0 test_ability_id_active
0 test_ability_id_not_active
0 event_test_filter_attack
Expand Down

0 comments on commit 9f4daef

Please sign in to comment.