Update the shroud unit tests and add a few more for cases new in 1.16

This commit is contained in:
Celtic Minstrel 2021-07-25 20:00:41 -04:00 committed by Celtic Minstrel
parent ab16cc614f
commit 99fd840b6d
2 changed files with 109 additions and 11 deletions

View file

@ -49,13 +49,11 @@
#define ASSERT_SHROUDED FILTER STATE
[lua]
code=<<
local locs = wesnoth.get_locations(wml.get_child(..., 'filter'))
--print(wml.tostring(wml.get_child(..., 'filter')))
--ilua._pretty_print(locs)
local locs = wesnoth.map.find(wml.get_child(..., 'filter'))
local state = (...).state
for _,loc in ipairs(locs) do
local x, y = loc[1], loc[2]
unit_test.assert_equal(wesnoth.is_shrouded(1, loc), state, string.format('shroud check at (%d,%d)', loc[1], loc[2]))
unit_test.assert_equal(wesnoth.sides.is_shrouded(1, loc), state, string.format('shroud check at (%d,%d)', loc[1], loc[2]))
end
>>
[args]
@ -72,7 +70,7 @@
[lua]
code=<<
local data = (...).data
unit_test.assert_equal(data, wesnoth.get_sides{side=1}[1].__cfg.shroud_data, 'data equal')
unit_test.assert_equal(data, wesnoth.sides[1].shroud_data, 'data equal')
>>
[args]
data={DATA}
@ -140,7 +138,7 @@
[event]
name=start
[lua]
code=<<wesnoth.place_shroud(1, {{7,5}})>>
code=<<wesnoth.sides.place_shroud(1, {{7,5}})>>
[/lua]
{ASSERT_SHROUDED x,y=7,5 true}
{SUCCEED}
@ -151,7 +149,17 @@
[event]
name=start
[lua]
code=<<wesnoth.place_shroud(1, (...).data)>>
code=<<
local ls = wesnoth.require "location_set"
local clear = ls.of_shroud_data((...).data)
local shroud = ls.create()
for x,y in wesnoth.current.map:iter() do
if not clear(x,y) then
shroud:insert(x,y)
end
end
wesnoth.sides.place_shroud(1, shroud:to_pairs())
>>
[args]
data="|
|
@ -176,11 +184,55 @@
[/event]
)}
{TEST_SHROUD_SCEN test_shroud_place_lua_all (
{TEST_SHROUD_SCEN test_shroud_override_data (
[event]
name=start
[lua]
code=<<wesnoth.place_shroud(1, 'all')>>
code=<<
local locs = wesnoth.map.parse_bitmap((...).data)
wesnoth.sides.override_shroud(1, locs)
>>
[args]
data="|
|
|
|
|
|
|
|
|
|
|
|
|00111
|000111
|00111
"
[/args]
[/lua]
{ASSERT_SHROUDED x,y=3,1-5 true}
{ASSERT_SHROUDED x,y=4,0-5 true}
{ASSERT_SHROUDED x,y=5,0-6 true}
{ASSERT_SHROUDED x,y=6,0-6 true}
{ASSERT_SHROUDED x,y=7,0-7 true}
{ASSERT_SHROUDED x,y=8,0-6 true}
{ASSERT_SHROUDED x,y=9,0-6 true}
{ASSERT_SHROUDED x,y=10,0-5 true}
{ASSERT_SHROUDED x,y=11,1-5 true}
{ASSERT_SHROUDED x,y=12,2-4 false}
{ASSERT_SHROUDED x,y=13,3-5 false}
{ASSERT_SHROUDED x,y=14,2-4 false}
{SUCCEED}
[/event]
)}
{TEST_SHROUD_SCEN test_shroud_override_all (
[event]
name=start
[lua]
code=<<wesnoth.sides.override_shroud(1, {})>>
[/lua]
{ASSERT_SHROUDED x,y=0-17,0-9 true}
{SUCCEED}
@ -203,13 +255,57 @@
[event]
name=start
[lua]
code=<<wesnoth.remove_shroud(1, {{13,8}})>>
code=<<wesnoth.sides.remove_shroud(1, {{13,8}})>>
[/lua]
{ASSERT_SHROUDED x,y=13,8 false}
{SUCCEED}
[/event]
)}
{TEST_SHROUD_SCEN test_shroud_remove_lua_data (
[event]
name=start
[lua]
code=<<
local locs = wesnoth.map.parse_bitmap((...).data)
wesnoth.sides.remove_shroud(1, locs)
>>
[args]
data="|
|
|
|
|
|
|
|
|
|
|
|
|00111
|000111
|00111
"
[/args]
[/lua]
{ASSERT_SHROUDED x,y=3,1-5 false}
{ASSERT_SHROUDED x,y=4,0-5 false}
{ASSERT_SHROUDED x,y=5,0-6 false}
{ASSERT_SHROUDED x,y=6,0-6 false}
{ASSERT_SHROUDED x,y=7,0-7 false}
{ASSERT_SHROUDED x,y=8,0-6 false}
{ASSERT_SHROUDED x,y=9,0-6 false}
{ASSERT_SHROUDED x,y=10,0-5 false}
{ASSERT_SHROUDED x,y=11,1-5 false}
{ASSERT_SHROUDED x,y=12,2-4 false}
{ASSERT_SHROUDED x,y=13,3-5 false}
{ASSERT_SHROUDED x,y=14,2-4 false}
{SUCCEED}
[/event]
)}
{TEST_SHROUD_SCEN test_shroud_modify_wml (
[event]
name=start

View file

@ -138,9 +138,11 @@
0 test_shroud_place_wml
0 test_shroud_place_lua
0 test_shroud_place_lua_data
0 test_shroud_place_lua_all
0 test_shroud_override_all
0 test_shroud_override_data
0 test_shroud_remove_wml
0 test_shroud_remove_lua
0 test_shroud_remove_lua_data
0 test_shroud_modify_wml
0 test_shroud_modify_lua
0 scatter_units