Data/Test: wmlindent run

[ci skip]

Addresses some of the whitespace issues mentioned in #2613
This commit is contained in:
Charles Dang 2018-03-09 11:22:00 +11:00
parent 33725add8f
commit 0cb9f0d622
18 changed files with 813 additions and 822 deletions

View file

@ -86,9 +86,9 @@
#enddef
#define FAIL
{RETURN ([false][/false])}
{RETURN ([false][/false])}
#enddef
#define SUCCEED
{RETURN ([true][/true])}
{RETURN ([true][/true])}
#enddef

View file

@ -1,17 +1,17 @@
#define AI_NOTIFICATION_STAGE CODE
[ai]
ai_algorithm=idle_ai
[stage]
id=check_validity
engine=lua
code={CODE}
[/stage]
[/ai]
[ai]
ai_algorithm=idle_ai
[stage]
id=check_validity
engine=lua
code={CODE}
[/stage]
[/ai]
#enddef
#define ASPECT_NOTIFICATION
<<
<<
local H = wesnoth.require('helper')
local expected = H.get_variable_array('expected')
local aspect = wesnoth.get_variable('test_attribute')
@ -29,15 +29,15 @@ end
#enddef
#define SPLIT LIST SEP
[split]
list={LIST}
key=value
separator={SEP}
[/split]
[split]
list={LIST}
key=value
separator={SEP}
[/split]
#enddef
#define AI_ASPECT_UNIT_TEST NAME TEST_ATTRIBUTE EXPECTED AIWML CONTENT
{AI_UNIT_TEST {NAME} {ASPECT_NOTIFICATION} {TEST_ATTRIBUTE} {EXPECTED} {AIWML} {CONTENT}}
{AI_UNIT_TEST {NAME} {ASPECT_NOTIFICATION} {TEST_ATTRIBUTE} {EXPECTED} {AIWML} {CONTENT}}
#enddef
#define AI_UNIT_TEST NAME TEST_CODE TEST_ATTRIBUTE EXPECTED AIWML CONTENT
@ -66,22 +66,22 @@ end
type = Orcish Grunt
id=bob
[ai]
ai_algorithm=idle_ai
ai_algorithm=idle_ai
[/ai]
[/side]
[event]
name=prestart
{VARIABLE is_valid true}
{VARIABLE test_attribute {TEST_ATTRIBUTE}}
[set_variables]
name=expected
{EXPECTED}
[/set_variables]
name=prestart
{VARIABLE is_valid true}
{VARIABLE test_attribute {TEST_ATTRIBUTE}}
[set_variables]
name=expected
{EXPECTED}
[/set_variables]
[/event]
[event]
name=turn 12 end
{RETURN {VARIABLE_CONDITIONAL is_valid boolean_equals true}}
name=turn 12 end
{RETURN {VARIABLE_CONDITIONAL is_valid boolean_equals true}}
[/event]
{CONTENT}

View file

@ -1,147 +1,147 @@
{AI_ASPECT_UNIT_TEST test_basic_simplified_aspect attack_depth
{SPLIT 3,5,5,3,7,7,5,3,5,5,7,7 ,}
{SPLIT 3,5,5,3,7,7,5,3,5,5,7,7 ,}
(
[ai]
time_of_day=first_watch,second_watch
attack_depth=7
[/ai]
[ai]
turns=1,4,8
attack_depth=3
[/ai]
[ai]
time_of_day=first_watch,second_watch
attack_depth=7
[/ai]
[ai]
turns=1,4,8
attack_depth=3
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_abbreviated_aspect attack_depth
{SPLIT 7,7,7,7,7,7,5,5,5,5,9,9 ,}
{SPLIT 7,7,7,7,7,7,5,5,5,5,9,9 ,}
(
[ai]
time_of_day=first_watch,second_watch
attack_depth=9
[attack_depth]
turns=1-6
value=7
[/attack_depth]
[/ai]
[ai]
time_of_day=first_watch,second_watch
attack_depth=9
[attack_depth]
turns=1-6
value=7
[/attack_depth]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_standard_aspect attack_depth
{SPLIT 7,7,7,7,7,7,7,7,7,7,7,7 ,
{SPLIT 7,7,7,7,7,7,7,7,7,7,7,7 ,
} (
[ai]
[aspect]
id=attack_depth
name=standard_aspect
value=7
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
name=standard_aspect
value=7
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_composite_aspect attack_depth
{SPLIT 5,5,14,14,14,14,5,5,5,5,12,12 ,}
{SPLIT 5,5,14,14,14,14,5,5,5,5,12,12 ,}
(
[ai]
[aspect]
id=attack_depth
[facet]
time_of_day=first_watch,second_watch
value=12
[/facet]
[facet]
turns=3-6
value=14
[/facet]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[facet]
time_of_day=first_watch,second_watch
value=12
[/facet]
[facet]
turns=3-6
value=14
[/facet]
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_lua_aspect attack_depth
{SPLIT 2,4,6,8,10,12,14,16,18,20,22,24 ,}
{SPLIT 2,4,6,8,10,12,14,16,18,20,22,24 ,}
(
[ai]
[aspect]
id=attack_depth
engine=lua
code=<<return wesnoth.current.turn * 2>>
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
engine=lua
code=<<return wesnoth.current.turn * 2>>
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_composite_facet attack_depth
{SPLIT 5,5,5,5,5,5,7,7,7,14,14,14 ,}
{SPLIT 5,5,5,5,5,5,7,7,7,14,14,14 ,}
(
[ai]
[aspect]
id=attack_depth
[facet]
name=composite_aspect
turns=7-12
[facet]
time_of_day=dusk,first_watch,second_watch
value=14
[/facet]
[default]
value=7
[/default]
[/facet]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[facet]
name=composite_aspect
turns=7-12
[facet]
time_of_day=dusk,first_watch,second_watch
value=14
[/facet]
[default]
value=7
[/default]
[/facet]
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_lua_facet attack_depth
{SPLIT 2,7,7,2,7,7,14,7,7,5,7,7 ,}
{SPLIT 2,7,7,2,7,7,14,7,7,5,7,7 ,}
(
[ai]
[aspect]
id=attack_depth
[facet]
engine=lua
time_of_day=dusk
code=<<return wesnoth.current.turn / 2>>
[/facet]
[facet]
engine=lua
time_of_day=dawn
code=<<return wesnoth.current.turn * 2>>
[/facet]
[default]
value=7
[/default]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[facet]
engine=lua
time_of_day=dusk
code=<<return wesnoth.current.turn / 2>>
[/facet]
[facet]
engine=lua
time_of_day=dawn
code=<<return wesnoth.current.turn * 2>>
[/facet]
[default]
value=7
[/default]
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_composite_default_facet attack_depth
{SPLIT 10,5,5,5,5,5,10,5,5,5,5,5 ,}
{SPLIT 10,5,5,5,5,5,10,5,5,5,5,5 ,}
(
[ai]
[aspect]
id=attack_depth
[default]
name=composite_aspect
[facet]
id=my_composite_default_attack_depth
time_of_day=dawn
value=10
[/facet]
[default]
value=5
[/default]
[/default]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[default]
name=composite_aspect
[facet]
id=my_composite_default_attack_depth
time_of_day=dawn
value=10
[/facet]
[default]
value=5
[/default]
[/default]
[/aspect]
[/ai]
) ()}
{AI_ASPECT_UNIT_TEST test_basic_lua_default_facet attack_depth
{SPLIT 1,2,3,4,5,6,7,8,9,10,11,12 ,}
{SPLIT 1,2,3,4,5,6,7,8,9,10,11,12 ,}
(
[ai]
[aspect]
id=attack_depth
[default]
engine=lua
code=<<return wesnoth.current.turn>>
[/default]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[default]
engine=lua
code=<<return wesnoth.current.turn>>
[/default]
[/aspect]
[/ai]
) ()}

View file

@ -1,223 +1,223 @@
{AI_ASPECT_UNIT_TEST test_modify_ai_delete_facet attack_depth
{SPLIT 7,7,7,7,7,7,5,5,5,5,5,5 ,}
{SPLIT 7,7,7,7,7,7,5,5,5,5,5,5 ,}
(
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
) (
[event]
name=turn 6 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth]
[/modify_ai]
[/event]
[event]
name=turn 6 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_change_facet attack_depth
{SPLIT 7,7,7,7,7,7,8,8,8,8,8,8 ,}
{SPLIT 7,7,7,7,7,7,8,8,8,8,8,8 ,}
(
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
) (
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth].facet[custom_depth]
[facet]
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth].facet[custom_depth]
[facet]
value=8
[/facet]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_replace_facet attack_depth
{SPLIT 7,7,7,7,8,8,8,8,5,5,5,5 ,}
{SPLIT 7,7,7,7,8,8,8,8,5,5,5,5 ,}
(
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
) (
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[]
[facet]
id=custom_depth
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth]
[/modify_ai]
[/event]
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[]
[facet]
id=custom_depth
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_add_facet attack_depth
{SPLIT 7,7,7,7,8,8,8,8,7,7,7,7 ,}
{SPLIT 7,7,7,7,8,8,8,8,7,7,7,7 ,}
(
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
[ai]
[attack_depth]
id=custom_depth
value=7
[/attack_depth]
[/ai]
) (
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[]
[facet]
id=custom_depth2
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth2]
[/modify_ai]
[/event]
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[]
[facet]
id=custom_depth2
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[custom_depth2]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_change_default_facet attack_depth
{SPLIT 5,5,5,5,7,7,7,7,8,8,8,8 ,}
{SPLIT 5,5,5,5,7,7,7,7,8,8,8,8 ,}
(
[ai]
[attack_depth]
turns=5-8
id=custom_depth
value=7
[/attack_depth]
[/ai]
[ai]
[attack_depth]
turns=5-8
id=custom_depth
value=7
[/attack_depth]
[/ai]
) (
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth].facet[default_facet]
[facet]
value=8
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth].facet[default_facet]
[facet]
value=8
[/facet]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_nested_facets attack_depth
{SPLIT 5,7,7,14,14,14,12,7,7,14,14,5 ,}
{SPLIT 5,7,7,14,14,14,12,7,7,14,14,5 ,}
(
[ai]
[aspect]
id=attack_depth
[facet]
id=composite_depth
name=composite_aspect
turns=2-11
[facet]
id=night_depth
time_of_day=dusk,first_watch,second_watch
value=14
[/facet]
[default]
id=my_default_attack_depth
value=7
[/default]
[/facet]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[facet]
id=composite_depth
name=composite_aspect
turns=2-11
[facet]
id=night_depth
time_of_day=dusk,first_watch,second_watch
value=14
[/facet]
[default]
id=my_default_attack_depth
value=7
[/default]
[/facet]
[/aspect]
[/ai]
) (
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[composite_depth].facet[]
[facet]
id=twilight_depth
time_of_day=dawn,dusk
value=12
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[composite_depth].facet[twilight_depth]
[/modify_ai]
[/event]
[event]
name=turn 4 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[composite_depth].facet[]
[facet]
id=twilight_depth
time_of_day=dawn,dusk
value=12
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[composite_depth].facet[twilight_depth]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_composite_default_facets attack_depth
{SPLIT 10,5,5,5,5,5,5,5,12,12,12,12 ,}
{SPLIT 10,5,5,5,5,5,5,5,12,12,12,12 ,}
(
[ai]
[aspect]
id=attack_depth
[default]
name=composite_aspect
[facet]
id=dawn_default
time_of_day=dawn
value=10
[/facet]
[default]
value=5
[/default]
[/default]
[/aspect]
[/ai]
[ai]
[aspect]
id=attack_depth
[default]
name=composite_aspect
[facet]
id=dawn_default
time_of_day=dawn
value=10
[/facet]
[default]
value=5
[/default]
[/default]
[/aspect]
[/ai]
) (
[event]
name=turn 4 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[default_facet].facet[dawn_default]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[default_facet].facet[]
[facet]
value=12
[/facet]
[/modify_ai]
[/event]
[event]
name=turn 4 end
[modify_ai]
action=delete
path=aspect[attack_depth].facet[default_facet].facet[dawn_default]
[/modify_ai]
[/event]
[event]
name=turn 8 end
[modify_ai]
action=add
path=aspect[attack_depth].facet[default_facet].facet[]
[facet]
value=12
[/facet]
[/modify_ai]
[/event]
)}
{AI_ASPECT_UNIT_TEST test_modify_ai_change_aspect attack_depth
{SPLIT 5,5,5,5,5,5,3,4,4,5,5,6 ,}
{SPLIT 5,5,5,5,5,5,3,4,4,5,5,6 ,}
() (
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth]
[aspect]
engine=lua
code=<<return math.floor(wesnoth.current.turn / 2)>>
[/aspect]
[/modify_ai]
[/event]
[event]
name=turn 6 end
[modify_ai]
action=change
path=aspect[attack_depth]
[aspect]
engine=lua
code=<<return math.floor(wesnoth.current.turn / 2)>>
[/aspect]
[/modify_ai]
[/event]
)}

View file

@ -222,7 +222,7 @@
name=start
{VARIABLE pass_test 0}
[event]
name=foo
name=foo
id=test
{VARIABLE pass_test 1}
[/event]
@ -232,4 +232,4 @@
[/fire_event]
{RETURN ({VARIABLE_CONDITIONAL pass_test equals 1})}
[/event]
)}
)}

View file

@ -4,87 +4,87 @@
# sets his level to 2.
{GENERIC_UNIT_TEST filter_this_unit_wml (
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
hitpoints="$($this_unit.max_hitpoints / 2)"
[/modify_unit]
{RETURN (
[have_unit]
id=bob
[filter_wml]
hitpoints="$($this_unit.max_hitpoints / 2)"
[/filter_wml]
[/have_unit]
)}
[/event]
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
hitpoints="$($this_unit.max_hitpoints / 2)"
[/modify_unit]
{RETURN (
[have_unit]
id=bob
[filter_wml]
hitpoints="$($this_unit.max_hitpoints / 2)"
[/filter_wml]
[/have_unit]
)}
[/event]
)}
{GENERIC_UNIT_TEST filter_this_unit_tl (
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
level="$($this_unit.max_hitpoints / 19)"
[/modify_unit]
{RETURN (
[have_unit]
id=bob
level="$($this_unit.max_hitpoints / 19)"
[/have_unit]
)}
[/event]
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
level="$($this_unit.max_hitpoints / 19)"
[/modify_unit]
{RETURN (
[have_unit]
id=bob
level="$($this_unit.max_hitpoints / 19)"
[/have_unit]
)}
[/event]
)}
{GENERIC_UNIT_TEST filter_this_unit_fai (
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
moves=3
[/modify_unit]
{RETURN (
[have_unit]
id=bob
formula="$this_unit.moves < $this_unit.max_moves"
[/have_unit]
)}
[/event]
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
moves=3
[/modify_unit]
{RETURN (
[have_unit]
id=bob
formula="$this_unit.moves < $this_unit.max_moves"
[/have_unit]
)}
[/event]
)}
{GENERIC_UNIT_TEST filter_fai_unit (
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
moves=3
[/modify_unit]
{RETURN (
[have_unit]
id=bob
formula="moves < max_moves"
[/have_unit]
)}
[/event]
[event]
name=prestart
[modify_unit]
[filter]
id=bob
[/filter]
moves=3
[/modify_unit]
{RETURN (
[have_unit]
id=bob
formula="moves < max_moves"
[/have_unit]
)}
[/event]
)}
{GENERIC_UNIT_TEST filter_fai_unit_error (
[event]
name=prestart
{RETURN (
[have_unit]
id=bob
formula="+ max_moves"
[/have_unit]
)}
[/event]
[event]
name=prestart
{RETURN (
[have_unit]
id=bob
formula="+ max_moves"
[/have_unit]
)}
[/event]
)}

View file

@ -22,7 +22,7 @@
id=alice
fog=yes
team_name=West
share_vision=shroud
share_vision=shroud
[/side]
[side]
side=2
@ -32,7 +32,7 @@
id=bob
fog=yes
team_name=East
share_vision=shroud
share_vision=shroud
[/side]
[side]
side=3
@ -42,7 +42,7 @@
id=dave
fog=yes
team_name=East
share_vision=shroud
share_vision=shroud
[/side]
[side]
side=4
@ -52,7 +52,7 @@
id=charlie
fog=yes
team_name=West
share_vision=shroud
share_vision=shroud
[/side]
{EVENTS}

View file

@ -1,181 +1,181 @@
# Note: All these loops must be set up to run either 0 or 1 times.
#define FOR_LOOP_TEST_STEP NAME START END STEP CONTENT
{GENERIC_UNIT_TEST {NAME} (
[event]
name=start
{VARIABLE n 0}
[for]
start,end,step={START},{END},{STEP}
[do]
{VARIABLE_OP n add 1}
{ASSERT (
{VARIABLE_CONDITIONAL i equals {START}}
[or]
{VARIABLE_CONDITIONAL i equals {END}}
[/or]
)}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
{CONTENT}
)}
{GENERIC_UNIT_TEST {NAME} (
[event]
name=start
{VARIABLE n 0}
[for]
start,end,step={START},{END},{STEP}
[do]
{VARIABLE_OP n add 1}
{ASSERT (
{VARIABLE_CONDITIONAL i equals {START}}
[or]
{VARIABLE_CONDITIONAL i equals {END}}
[/or]
)}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
{CONTENT}
)}
#enddef
{FOR_LOOP_TEST_STEP forloop_all_zero 0 0 0 (
[event]
name=no_error
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=no_error
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_step_zero 0 1 0 (
[event]
name=no_error
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=no_error
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_once_positive 0 0 1 (
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 1})}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 1})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_once_negative 0 0 -1 (
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 1})}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 1})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_twice_matched 0 1 1 (
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 2})}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 2})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_twice_unmatched 0 1 -1 (
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 0})}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 0})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_step_large_positive 0 10 10 (
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{FOR_LOOP_TEST_STEP forloop_step_large_negative 10 0 -10 (
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
#undef FOR_LOOP_TEST_STEP
{GENERIC_UNIT_TEST forloop_empty_array (
[event]
name=start
{VARIABLE n 0}
[for]
array=nothing
[do]
{VARIABLE_OP n add 1}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=start
{VARIABLE n 0}
[for]
array=nothing
[do]
{VARIABLE_OP n add 1}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{SUCCEED}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
#define FOR_LOOP_ARRAY_TEST NAME FINAL_VALUE REVERSE
{GENERIC_UNIT_TEST {NAME} (
[event]
name=start
[set_variables]
name=array
[value]
value=10
[/value]
[value]
value=7
[/value]
[value]
value=2
[/value]
[/set_variables]
{VARIABLE n 0}
[for]
array=array
reverse={REVERSE}
[do]
{VARIABLE n $array[$i].value}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals {FINAL_VALUE}})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
{GENERIC_UNIT_TEST {NAME} (
[event]
name=start
[set_variables]
name=array
[value]
value=10
[/value]
[value]
value=7
[/value]
[value]
value=2
[/value]
[/set_variables]
{VARIABLE n 0}
[for]
array=array
reverse={REVERSE}
[do]
{VARIABLE n $array[$i].value}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals {FINAL_VALUE}})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
#enddef
{FOR_LOOP_ARRAY_TEST forloop_array 2 no}
@ -185,62 +185,61 @@
#undef FOR_LOOP_ARRAY_TEST
{GENERIC_UNIT_TEST forloop_array_mutate (
[event]
name=start
[set_variables]
name=array
[value]
value=10
[/value]
[value]
value=7
[/value]
[value]
value=2
[/value]
[value]
value=37
[/value]
[/set_variables]
{VARIABLE n 0}
[for]
array=array
[do]
{VARIABLE n $array[$i].value}
{CLEAR_VARIABLE ("array[$($array.length - 1)]")}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 7})}
[/event]
[event]
name=start
{FAIL}
[/event]
[event]
name=start
[set_variables]
name=array
[value]
value=10
[/value]
[value]
value=7
[/value]
[value]
value=2
[/value]
[value]
value=37
[/value]
[/set_variables]
{VARIABLE n 0}
[for]
array=array
[do]
{VARIABLE n $array[$i].value}
{CLEAR_VARIABLE ("array[$($array.length - 1)]")}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
[event]
name=no_error
{RETURN ({VARIABLE_CONDITIONAL n equals 7})}
[/event]
[event]
name=start
{FAIL}
[/event]
)}
#define FOR_LOOP_TEST_STEP NAME START END EXTRA CONTENT
{GENERIC_UNIT_TEST NAME (
[event]
name=start
{VARIABLE n 0}
[for]
start,end={START},{END}
{EXTRA}
[do]
{VARIABLE_OP n add 1}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
{CONTENT}
)}
{GENERIC_UNIT_TEST NAME (
[event]
name=start
{VARIABLE n 0}
[for]
start,end={START},{END}
{EXTRA}
[do]
{VARIABLE_OP n add 1}
[/do]
[/for]
[fire_event]
name=no_error
[/fire_event]
[/event]
{CONTENT}
)}
#enddef

View file

@ -1,81 +1,81 @@
{GENERIC_UNIT_TEST check_interrupts_break (
[event]
name=start
{VARIABLE x 0}
[while]
[true][/true]
[do]
[if]
{VARIABLE_CONDITIONAL x greater_than 5}
[then]
[break][/break]
[/then]
[/if]
{VARIABLE_OP x add 1}
[/do]
[/while]
{RETURN ({VARIABLE_CONDITIONAL x equals 6})}
[/event]
[event]
name=start
{VARIABLE x 0}
[while]
[true][/true]
[do]
[if]
{VARIABLE_CONDITIONAL x greater_than 5}
[then]
[break][/break]
[/then]
[/if]
{VARIABLE_OP x add 1}
[/do]
[/while]
{RETURN ({VARIABLE_CONDITIONAL x equals 6})}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_return (
[event]
name=start
{VARIABLE x 0}
[while]
[true][/true]
[do]
[if]
{VARIABLE_CONDITIONAL x greater_than 5}
[then]
[return][/return]
[/then]
[/if]
{VARIABLE_OP x add 1}
[/do]
[/while]
{FAIL}
[/event]
[event]
name=start
{RETURN ({VARIABLE_CONDITIONAL x equals 6})}
[/event]
[event]
name=start
{VARIABLE x 0}
[while]
[true][/true]
[do]
[if]
{VARIABLE_CONDITIONAL x greater_than 5}
[then]
[return][/return]
[/then]
[/if]
{VARIABLE_OP x add 1}
[/do]
[/while]
{FAIL}
[/event]
[event]
name=start
{RETURN ({VARIABLE_CONDITIONAL x equals 6})}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_continue (
[event]
name=start
{VARIABLE x 0}
[while]
{VARIABLE_CONDITIONAL x less_than 5}
[do]
{VARIABLE_OP x add 5}
[continue][/continue]
{FAIL}
[/do]
[/while]
{RETURN ({VARIABLE_CONDITIONAL x equals 5})}
[/event]
[event]
name=start
{VARIABLE x 0}
[while]
{VARIABLE_CONDITIONAL x less_than 5}
[do]
{VARIABLE_OP x add 5}
[continue][/continue]
{FAIL}
[/do]
[/while]
{RETURN ({VARIABLE_CONDITIONAL x equals 5})}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_break_global (
[event]
name=start
[break][/break]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=start
[break][/break]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_continue_global (
[event]
name=start
[lua]
code=<<
[event]
name=start
[lua]
code=<<
local H = wesnoth.require "helper"
local A = H.set_wml_action_metatable{}
local function continue()
@ -86,112 +86,112 @@
if err then wesnoth.fire_event "success"
else wesnoth.fire_event "fail" end
>>
[/lua]
[/event]
[event]
name=success
[endlevel]
result=victory
linger_mode = yes
[/endlevel]
[/event]
[event]
name=fail
[endlevel]
result=defeat
linger_mode = yes
[/endlevel]
[/event]
[/lua]
[/event]
[event]
name=success
[endlevel]
result=victory
linger_mode = yes
[/endlevel]
[/event]
[event]
name=fail
[endlevel]
result=defeat
linger_mode = yes
[/endlevel]
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_return_nested (
[event]
name=start
[command]
[return][/return]
{FAIL}
[/command]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=start
[command]
[return][/return]
{FAIL}
[/command]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_elseif (
[event]
name=start
{VARIABLE x 9}
[if]
{VARIABLE_CONDITIONAL x greater_than 10}
[then]
{FAIL}
[/then]
[elseif]
{VARIABLE_CONDITIONAL x less_than 10}
[then]
[return][/return]
[/then]
[/elseif]
[else]
[wml_message]
message="Reached the [else] block!"
logger=error
[/wml_message]
{FAIL}
[/else]
[/if]
[wml_message]
message="Passed the [if] block!"
logger=error
[/wml_message]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=start
{VARIABLE x 9}
[if]
{VARIABLE_CONDITIONAL x greater_than 10}
[then]
{FAIL}
[/then]
[elseif]
{VARIABLE_CONDITIONAL x less_than 10}
[then]
[return][/return]
[/then]
[/elseif]
[else]
[wml_message]
message="Reached the [else] block!"
logger=error
[/wml_message]
{FAIL}
[/else]
[/if]
[wml_message]
message="Passed the [if] block!"
logger=error
[/wml_message]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
{GENERIC_UNIT_TEST check_interrupts_case (
[event]
name=start
{VARIABLE x 0}
[switch]
variable=x
[case]
value=1,3,5,7,9
{FAIL}
[/case]
[case]
value=0,2,4,6,8
[return][/return]
[/case]
[case]
value=0
[wml_message]
message="Reached next [case] block!"
logger=error
[/wml_message]
{FAIL}
[/case]
[else]
[wml_message]
message="Reached the [else] block!"
logger=error
[/wml_message]
{FAIL}
[/else]
[/switch]
[wml_message]
message="Passed the [switch] block!"
logger=error
[/wml_message]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
[event]
name=start
{VARIABLE x 0}
[switch]
variable=x
[case]
value=1,3,5,7,9
{FAIL}
[/case]
[case]
value=0,2,4,6,8
[return][/return]
[/case]
[case]
value=0
[wml_message]
message="Reached next [case] block!"
logger=error
[/wml_message]
{FAIL}
[/case]
[else]
[wml_message]
message="Reached the [else] block!"
logger=error
[/wml_message]
{FAIL}
[/else]
[/switch]
[wml_message]
message="Passed the [switch] block!"
logger=error
[/wml_message]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}

View file

@ -1,77 +1,77 @@
{GENERIC_UNIT_TEST "test_wml_actions" (
[event]
name = start
[lua]
code = <<
[event]
name = start
[lua]
code = <<
function wesnoth.wml_actions.foo(cfg)
if cfg.bar then
wesnoth.set_variable("result", cfg.bar)
end
end
>>
[/lua]
[/lua]
{VARIABLE result 0}
{ASSERT {VARIABLE_CONDITIONAL result equals 0}}
{VARIABLE result 0}
{ASSERT {VARIABLE_CONDITIONAL result equals 0}}
[foo]
bar = 1
[/foo]
[foo]
bar = 1
[/foo]
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
[foo]
baz = 0
[/foo]
[foo]
baz = 0
[/foo]
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
[foo]
bar = 2
[/foo]
[foo]
bar = 2
[/foo]
{RETURN {VARIABLE_CONDITIONAL result equals "2"}}
[/event]
{RETURN {VARIABLE_CONDITIONAL result equals "2"}}
[/event]
)}
{GENERIC_UNIT_TEST "test_wml_conditionals" (
[event]
name = start
[lua]
code = <<
[event]
name = start
[lua]
code = <<
function wesnoth.wml_conditionals.foo(cfg)
return (cfg.bar == "baz")
end
>>
[/lua]
[/lua]
{ASSERT ([foo]
bar = "baz"
[/foo])}
{ASSERT ([not]
[foo]
bar = "boo"
[/foo]
[/not])}
{ASSERT ([foo]
bar = "baz"
[/foo]
[or]
[foo]
bar = "boo"
[/foo]
[/or])}
{ASSERT ([not]
[foo]
bar = "baz"
[/foo]
[and]
[foo]
bar = "boo"
[/foo]
[/and]
[/not])}
{ASSERT ([foo]
bar = "baz"
[/foo])}
{ASSERT ([not]
[foo]
bar = "boo"
[/foo]
[/not])}
{ASSERT ([foo]
bar = "baz"
[/foo]
[or]
[foo]
bar = "boo"
[/foo]
[/or])}
{ASSERT ([not]
[foo]
bar = "baz"
[/foo]
[and]
[foo]
bar = "boo"
[/foo]
[/and]
[/not])}
{SUCCEED}
[/event]
{SUCCEED}
[/event]
)}

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@