wesnoth/data/test/scenarios
Steve Cotton 2b8e887bcf Fix [resistance_defaults] and [terrain_defaults] (issue #5308)
The bug introduced in fcd0ceda is fixed by ensuring that movetype::merge() is
called with the strings "movement_costs", "vision_costs" and "jamming_costs"
instead of "movement", "vision" and "jamming".

Both [terrain_defaults][movement] and [terrain_defaults][movement_costs] are
supported and equivalent, as added to the master branch in 3522eb2c.

These now work again:

    [resistance_defaults]
        id="special_res_for_test"
        default="30"
    [/resistance_defaults]

    [resistance_defaults]
        id="copy_of_arcane"
        default="(arcane)"
    [/resistance_defaults]

    [terrain_defaults]
        id="special_terrain_for_test"
        [movement]
            default="(swamp_water + 1)"
            orcishfoot="(swamp_water * 2)"
        [/movement]
    [/terrain_defaults]

Formulas can now access other parts of the movetype too, as this allowed the
code to be the same as in 1.15:

    [terrain_defaults]
        id="special_terrain_for_test"
        [movement_costs]
            default="(swamp_water + 1)"
            orcishfoot="(vision_costs.swamp_water * 2)"
        [/movement_costs]
    [/terrain_defaults]
    [terrain_defaults]
        id="special_terrain_for_test"
        [defense]
            default="(20 + 7 * movement_costs.special_terrain_for_test)"
        [/defense]
    [/terrain_defaults]

The formula handling will recognise "resistance", "movement_costs",
"vision_costs", "jamming_costs" and "defense". For [resistance_defaults], the
formula will recognise both "(arcane)" and "(resistance.arcane)" as equivalent,
similarly for [terrain_defaults] "(swamp_water)" is a shorthand for whichever
subtag is being patched.

A [terrain_defaults] tag may use data added in a previous [terrain_defaults],
as in the examples above where the second tag's [defense] is based on the first
tag's [movement_costs], this gives orcish grunts on the special terrain a 62%
chance to be hit. However, relying on data in the same [terrain_defaults] that
creates or changes it is unsupported - if the [movement_costs] and [defense]
were in a single [terrain_defaults] tag then the result would be implementation
defined, because no guarantee is made of the order in which the children of the
tag are processed.

The unit tests for [terrain_defaults] and [resistance_defaults] must stay
out-of-tree until we support some method of testing them without affecting the
core units' stats during other tests. The test added here is limited to
checking the ways that WML can read the stats, it's also a framework for the
out-of-tree parts to use.

This is a squashed cherry pick of these commits from 1.15:
* 72863e578b (the unit test)
* 0ba433203e
* 3522eb2c2a (adding the aliases)
* 0035b776d7 (fix for empty children)
2021-03-05 18:09:19 +01:00
..
ai Do not load helper.lua where it is not used any more 2018-05-12 17:41:42 -07:00
break_replay_with_lua_random.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
bytecode.bin check_utf8.sh: don't check the Lua bytecode file 2018-07-27 23:34:11 +03:00
characterize_pathfinding.cfg Replace remaining uses of FOREACH macro 2018-05-14 17:12:01 -07:00
conditionals.cfg Add SUCCEED/FAIL macros for WML test cases 2015-09-22 23:13:38 -04:00
empty_test.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
event_handlers_in_events.cfg Data/Test: wmlindent run 2018-03-09 11:22:00 +11:00
facing.cfg Add SUCCEED/FAIL macros for WML test cases 2015-09-22 23:13:38 -04:00
feeding.cfg disallow attacking with disabled attacks via [do_command] 2018-06-17 22:56:50 +02:00
filter_this_unit.cfg Separate unit test statuses for WML exceptions and strict warnings (fixes #4471) 2019-12-24 18:13:13 +01:00
filter_vision.cfg Data/Test: wmlindent run 2018-03-09 11:22:00 +11:00
for-loops.cfg Data/Test: wmlindent run 2018-03-09 11:22:00 +11:00
has_ally.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
interrupts.cfg Do not load helper.lua where it is not used any more 2018-05-12 17:41:42 -07:00
move_skip_sighted.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
order_of_nested_events.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
prestart_settings.cfg fix a bunch of typos found by codespell in data directory. 2018-02-06 23:03:06 +11:00
readme.txt Fix readme files about unit test scenarios 2014-05-19 17:13:27 -04:00
recruit_facing.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
scatter_units.cfg Add test for #3663 2018-10-27 20:41:29 +00:00
sighted_events.cfg fix a bunch of typos found by codespell in data directory. 2018-02-06 23:03:06 +11:00
store_locations.cfg test [store_locations], and try to characterize [find_path] 2014-05-27 20:30:30 -04:00
swarm_disables_upgrades.cfg Add WML unit test for unupgradable (#3336) 2018-07-22 17:51:22 -04:00
test_assert.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
test_berzerk_firststrike.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
test_check_victory.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
test_clear.cfg Lua code: replace deprecated wesnoth.get_all_vars() calls 2018-05-12 17:41:37 -07:00
test_cve_2018_1999023.cfg Extend the first CVE-2018-1999023 unit test to also try loadstring() 2018-07-28 07:38:00 +03:00
test_cve_2018_1999023_2.cfg wml test for cve-2018-1999023 2018-07-24 02:52:57 +02:00
test_dofile.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
test_end_turn.cfg Add SUCCEED/FAIL macros for WML test cases 2015-09-22 23:13:38 -04:00
test_event_names_and_order.cfg Added some event unit tests by @Pentarctagon 2018-01-11 13:12:28 -05:00
test_for_tag.cfg Add WML unit tests for [for] tag 2017-06-21 21:18:24 -05:00
test_grunt_tod_damage.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
test_lua.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
test_lua_wml.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
test_lua_wml_tagnames.cfg Remove some uses of set_wml_tag_metatable 2018-03-24 13:53:20 -04:00
test_max_menu_items.cfg Ran wmlindnet on unit tests. Some formatting had to be manually corrected 2015-01-05 20:42:12 +11:00
test_menu_items.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
test_move.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
test_move_unit.cfg Add SUCCEED/FAIL macros for WML test cases 2015-09-22 23:13:38 -04:00
test_movetype.cfg Add unit tests for movement and vision costs 2019-07-31 14:07:00 +02:00
test_relative_dir.cfg Allow launching test scenarios from the titlescreen 2017-05-04 19:20:44 -04:00
test_require.cfg Lua code: replace deprecated wesnoth.set_variable() calls 2018-05-12 17:41:28 -07:00
test_resistances.cfg Fix [resistance_defaults] and [terrain_defaults] (issue #5308) 2021-03-05 18:09:19 +01:00
test_return.cfg refactor assert, return, two_plus_two, to each be one file 2014-05-16 22:45:54 -04:00
test_role_types.cfg Add SUCCEED/FAIL macros for WML test cases 2015-09-22 23:13:38 -04:00
test_unit_map.cfg Replace most instances of a single-hex [terrain_mask] action with [terrain] 2015-10-07 17:00:53 +11:00
test_victory_attacks.cfg Fix WML unit tests 2015-10-07 20:09:57 -04:00
two_plus_two.cfg refactor assert, return, two_plus_two, to each be one file 2014-05-16 22:45:54 -04:00
unit_spawns_at_nearest_vacant_hex.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
units_offmap_goto_recall.cfg wmlindent pass on data/test/scenarios/, safe subset 2014-07-03 19:56:35 -04:00
xp_mod.cfg Ran wmlindnet on unit tests. Some formatting had to be manually corrected 2015-01-05 20:42:12 +11:00

This directory contains both the scenarios used by C++ unit tests and those which are
WML unit tests.

For the C++ unit tests, it is recommended to reuse the same scenario file as much as possible
and just inject WML into it.
Injection can be done by adding a config object containing event code and then registering that
manually for game_events.

WML unit tests are self-contained scenario files to test a specific area of WML. They can be
implemented with the GENERIC_UNIT_TEST macro.