From bd8a5fa038fbcd546ca5b7acee45b2aaa267ee97 Mon Sep 17 00:00:00 2001 From: Steve Cotton Date: Fri, 16 Aug 2024 20:35:33 +0200 Subject: [PATCH] Add tests for [store_locations] with an SUF Prompted by a discussion over [filter_weapon][not] when a unit has no usable weapon. --- ...store_locations_and_or_not_unit_filter.cfg | 103 ++++++++++++++++++ .../store_locations_with_unit_filter.cfg | 34 ++++++ wml_test_schedule | 2 + 3 files changed, 139 insertions(+) create mode 100644 data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_and_or_not_unit_filter.cfg create mode 100644 data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_with_unit_filter.cfg diff --git a/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_and_or_not_unit_filter.cfg b/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_and_or_not_unit_filter.cfg new file mode 100644 index 00000000000..9c54c24e9c5 --- /dev/null +++ b/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_and_or_not_unit_filter.cfg @@ -0,0 +1,103 @@ +#wmllint: no translatables + +##### +# API(s) being tested: [store_locations][and][filter],[store_locations][or][filter],[store_locations][not][filter] +## +# Expected end state: +# Wrapping the SUF in [and], [or] or [not] applies the expected logic. +##### +{GENERIC_UNIT_TEST "store_locations_and_or_not_unit_filter" ( + [event] + name = start + + # Explicit [and], explicit [and] + [store_locations] + [and] + [filter] + race=elf + [/filter] + [/and] + [and] + [filter] + race=orc + [/filter] + [/and] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 0})} + + # Implicit [and], explicit [and] + [store_locations] + [filter] + race=elf + [/filter] + [and] + [filter] + race=orc + [/filter] + [/and] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 0})} + + # Explicit [and], explicit [or] + [store_locations] + [and] + [filter] + race=elf + [/filter] + [/and] + [or] + [filter] + race=orc + [/filter] + [/or] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 2})} + + # Implicit [and], explicit [or] + [store_locations] + [filter] + race=elf + [/filter] + [or] + [filter] + race=orc + [/filter] + [/or] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 2})} + + # Excluding with [not] + # Including the borders, the map is 18 x 10 + [store_locations] + [not] + [filter] + race=elf + [/filter] + [/not] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 179})} + + # Excluding with [not], [not] + [store_locations] + [not] + [filter] + race=elf + [/filter] + [/not] + [not] + [filter] + race=orc + [/filter] + [/not] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 178})} + + {SUCCEED} + [/event] +)} diff --git a/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_with_unit_filter.cfg b/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_with_unit_filter.cfg new file mode 100644 index 00000000000..560071e5873 --- /dev/null +++ b/data/test/scenarios/wml_tests/ScenarioWML/EventWML/ActionWML/InternalActionsWML/store_locations_with_unit_filter.cfg @@ -0,0 +1,34 @@ +#wmllint: no translatables + +##### +# API(s) being tested: [store_locations][filter] +## +# Expected end state: +# When an SUF is given to [store_locations], only the hexes with matching units are stored. +##### +{GENERIC_UNIT_TEST "store_locations_with_unit_filter" ( + [event] + name = start + + # This will store the hexes that Alice and Bob are standing on + [store_locations] + [filter] + [/filter] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 2})} + + # With a filter that excludes elves, this will store the hex that Bob is standing on + [store_locations] + [filter] + [not] + race=elf + [/not] + [/filter] + variable=tmp + [/store_locations] + {ASSERT ({VARIABLE_CONDITIONAL tmp.length equals 1})} + + {SUCCEED} + [/event] +)} diff --git a/wml_test_schedule b/wml_test_schedule index d2370014bb6..00e33ac8c0b 100644 --- a/wml_test_schedule +++ b/wml_test_schedule @@ -445,6 +445,8 @@ 0 filter_this_unit_formula 0 filter_formula_unit 9 filter_formula_unit_error +0 store_locations_with_unit_filter +0 store_locations_and_or_not_unit_filter # Interrupt tag tests 0 check_interrupts_break 0 check_interrupts_return