Commit graph

60 commits

Author SHA1 Message Date
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
Steve Cotton
bba67f2bb3 Separate unit test statuses for WML exceptions and strict warnings (fixes #4471)
Backported to 1.14 so that this mechanism can be used instead of a793bce96's
method of running the cve_2018_1999023 test in non-strict mode, which means
that the test now passes without making equivalent-to-a793bce96 changes to
projectfiles/VC12/WML_tests.cmd and projectfiles/VC16/WML_tests.cmd.

This was part of working out whether a subset of the "fail" tests could be run
in one Wesnoth instance. To run a test that returns TEST_FAIL_BROKE_STRICT with
any other test would require a mechanism to reset lg::broke_strict()'s flag.

All tests that fail with an {ASSERT} will also set the lg::broke_strict() flag,
the tests with the new status are only those that would pass without the strict
flag.

In the SUF tests, change a test from fail-on-success to breaks-strict, rename
the formula tests and add some comments. The rename is because "fai" is
"Formula AI", an obsolete name for WFL.

(cherry-picked from commit 7359fddecb)
2019-12-24 18:13:13 +01:00
Steve Cotton
aa9ff15a0f Add unit tests for movement and vision costs
Includes tests for changing the terrain costs, and aliased terrains,

(cherry picked from commit 358f564301)
2019-07-31 14:07:00 +02:00
josteph
36c796852b Add test for #3663 2018-10-27 20:41:29 +00:00
Jyrki Vesterinen
a793bce969 WML unit tests: disable strict mode for the first CVE-2018-1999023 test
The test calls a deprecated function (on purpose) and thus will always log
an error.
2018-07-28 08:09:06 +03:00
gfgtdf
164ff74f0f wml test for cve-2018-1999023
this test whether we succesfully prevent the exceution and parsing of
precompiled lua chunks, which can be used to break the lua sandbox.
This test does not cover all affected functions in particular not the ai
code that loads lua chunks.
2018-07-24 02:52:57 +02:00
Toom
739df85e1d Add WML unit test for unupgradable (#3336)
* Add WML unit test for unupgradable

* Follow [do_command] requirements
2018-07-22 17:51:22 -04:00
Jyrki Vesterinen
1386e3945c Added unit tests about which WML tag names Lua API accepts 2018-01-17 23:23:13 +02:00
Charles Dang
8ae99bc86a Added some event unit tests by @Pentarctagon
Tests event execution order and events with variable names.
2018-01-11 13:12:28 -05:00
Gregory A Lundberg
eaccef65f8 Add WML unit tests for [for] tag 2017-06-21 21:18:24 -05:00
Celtic Minstrel
cb0fad078a WML unit tests for simple aspects 2016-03-22 07:22:22 -07:00
Celtic Minstrel
240b5f61a7 Output formula errors in unit filters to WML error stream
(And consider them to match no units)
2016-03-17 23:27:03 -04:00
Celtic Minstrel
26a2638f2c Make the formula and Lua views of a unit coincide more closely
Several keys were either missing or misnamed in the formula view.
These have been changed to match the Lua and WML names for the keys.
This affects canrecruit, moves, and max_moves, as well as status.

In addition, a large number of keys were missing entirely from the formula view.
Most of these keys have now been added and can be accessed from formulas.
A few that have little use in filters (such as image_mods or profile) are still missing.

The Lua view missed a few keys that the formula view did provide.
Although these could in principle have been obtained by using the special __cfg key,
they have now been added to the Lua view anyway.
2016-03-17 23:27:03 -04:00
Celtic Minstrel
aa2e24d1b7 Finally fix all the [for] issues. Probably.
(With unit tests to back it up!)

- Fixes [for]step=0
- Fixes [for]start,stop=0,0
- Fixes [for]start,end,step=0,1,-1
- Probably fixes several other things too
2015-10-06 13:51:28 -04:00
Celtic Minstrel
7e26e09061 Fix erroneous handling of [break]/[continue] in [elseif] 2015-09-23 00:25:31 -04:00
Celtic Minstrel
aec99429c4 Merge branch 'break-continue' into foreach 2015-09-20 00:48:39 -04:00
Celtic Minstrel
3c329408ce Implement [break], [continue], [return] tags (they take no arguments) 2015-09-20 00:47:23 -04:00
Celtic Minstrel
a5184181df Fix SUF $this_unit only working within [filter_wml] 2015-09-19 00:19:26 -04:00
Elvish_Hunter
d4a3c76447 Improved the [role] unit test
A new unit test, called 'test_role_lua' was added, to ensure that the [role]
tag could be used from Lua.
Also, in the first unit test the types list is stored in a variable, to
ensure that variable substitution works as intended
2015-06-13 21:23:40 +02:00
Elvish_Hunter
1b239aa3e6 Added a new unit test for [role] 2015-06-10 22:07:28 +02:00
Chris Beck
f4c99b3a1a fixup wesnoth.wml_conditionals, add unit tests 2015-04-10 14:16:21 -04:00
Charles Dang
0911b1f4d5 Added some conditional unit tests 2015-04-03 08:31:13 +11:00
Chris Beck
af06820729 re-enable some tests related to pathfinding that were disabled
In relation to bug #23188 and PR # 364
2015-02-28 22:49:03 -05:00
gfgtdf
10a5851a79 Update wml_test_schedule 2015-01-24 13:49:36 +01:00
Chris Beck
8459bf7104 add lua function "fire_wml_menu_item" and unit tests for menu items
this commit also changed slightly the way that wml menu events
are synced. previously they were run via "run_in_synced_context",
now they are run via "run_in_synced_context_if_not_already", which
makes it safe to fire them from lua (a synced context).
2015-01-06 21:42:52 -05:00
Chris Beck
18b5059b23 add some [time_area] unit tests 2015-01-05 02:34:09 -05:00
Chris Beck
6a3321d0db fix bug #23130 (xp modifier not working), add unit tests
Reverts commit e85c37e161 which was
an error.

I chose to use a scoped_pointer this time around because the
definition of play_controller should not actually depend on the
complete definition of unit_type.
2015-01-02 18:03:24 -05:00
Chris Beck
a273be5520 add a wml unit test for {CLEAR_VARIABLE} macro 2014-12-29 00:39:14 -05:00
Chris Beck
2239ab3f65 add a unit test for lua get_sides return object 2014-12-26 01:07:57 -05:00
Chris Beck
d1d0990235 add a unit test for wesnoth.require 2014-12-06 23:32:29 -05:00
Chris Beck
69d7924df5 add a wml unit test for lua dofile 2014-12-05 15:30:12 -05:00
Chris Beck
01fa3ff298 register the tests of {MOVE_UNIT} macro with the test schedule 2014-10-18 16:02:14 -04:00
Chris Beck
acc534d86b disable a wml unit test that occasionally takes too long
"characterize_pathfinding_one"
2014-10-10 18:14:33 -04:00
Chris Beck
6cb9c518c7 Merge branch 'has_ally_master'
Conflicts:
	wml_test_schedule
2014-07-12 11:05:18 -04:00
Chris Beck
5a64d43fae add [has_ally],[has_enemy] tags for standard side filter
Unlike [allied_with] and [enemy_of], these will match if only if
there is *any* ally or enemy matching the filter. The other versions
of the tag match only if all sides matching the filter are
allied / opposed.

This commit also adds a unit test that checks that it works as
expected.
2014-07-12 10:33:56 -04:00
Chris Beck
72d91daed0 fixup [filter_vision] tags
This is the master version of PR #237, with unit tests.
2014-07-12 09:59:24 -04:00
Chris Beck
14808e186b add unit test for an object-based "feeding" ability
based on tekelili's forum post here:
http://forums.wesnoth.org/viewtopic.php?f=8&t=40449#p572206
2014-06-21 22:08:32 -04:00
Chris Beck
5e9d356c9f unit tests for defining custom event handlers in events and firing 2014-06-21 16:58:40 -04:00
Chris Beck
f43cb8edc2 add tests for scenario ending by killing enemy leader
Tests killing, killing on retal, and levelling up on killing,
in various configurations.
2014-06-07 17:21:00 -04:00
Chris Beck
3a102774b5 fixup pathfind tests, add reachability tests 2014-05-28 01:31:09 -04:00
Chris Beck
6cb367594b test [store_locations], and try to characterize [find_path] 2014-05-27 20:30:30 -04:00
Alexander van Gessel
4d7de12e47 Unit tests for deterministic unit facings 2014-05-27 17:30:13 +02:00
Chris Beck
f664b4e5af add test of [modify_unit] facing= attribute 2014-05-26 23:34:48 -04:00
Chris Beck
b272239ea9 add replace_schedule in prestart test 2014-05-26 20:14:16 -04:00
Chris Beck
ec5ec4fb38 add tests of modify_turns tag 2014-05-26 20:02:05 -04:00
Chris Beck
7cc62266e9 unit tests for giving gold in prestart 2014-05-26 19:06:00 -04:00
Chris Beck
d129d80ebe Add unit tests for check victory function
Mainly focused on defeat_condition field right now... woudl be good
to add some that test victory_when_enemies_defeated.
2014-05-22 17:21:53 -04:00
Chris Beck
86fea3c551 add unit test for berzerk + firststrike interaction 2014-05-16 23:53:28 -04:00
Chris Beck
af4b671266 add unit test for basic unit map functionality 2014-05-16 22:23:48 -04:00
Chris Beck
d7374f4080 add test_move unit tests 2014-05-16 21:25:23 -04:00