Add unit tests for [break] and [return] during [fire_event]

Fixes #7084.
This commit is contained in:
Steve Cotton 2022-11-02 11:45:54 +01:00 committed by Steve Cotton
parent 0f47405a96
commit b18b0e0f55
2 changed files with 54 additions and 2 deletions

View file

@ -103,6 +103,31 @@
[/event]
)}
#####
# API(s) being tested: [fire_event], [break]
##
# Expected end state:
# [break] outside a loop is documented to be the same as [return], so skips the entire rest of the firing event, not just fired event.
#####
{GENERIC_UNIT_TEST check_interrupts_break_nested_event (
[event]
name=function_with_interrupt
[break][/break]
{FAIL}
[/event]
[event]
name=start
[fire_event]
name=function_with_interrupt
[/fire_event]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
#####
# API(s) being tested: wesnoth.wml_actions.continue
##
@ -149,7 +174,7 @@
# Expected end state:
# [return] skips the entire rest of the event, not just the [command] it's nested in.
#####
{GENERIC_UNIT_TEST check_interrupts_return_nested (
{GENERIC_UNIT_TEST check_interrupts_return_nested_command (
[event]
name=start
[command]
@ -164,6 +189,31 @@
[/event]
)}
#####
# API(s) being tested: [fire_event], [return]
##
# Expected end state:
# [return] skips the entire rest of the firing event, not just fired event.
#####
{GENERIC_UNIT_TEST check_interrupts_return_nested_event (
[event]
name=function_with_interrupt
[return][/return]
{FAIL}
[/event]
[event]
name=start
[fire_event]
name=function_with_interrupt
[/fire_event]
{FAIL}
[/event]
[event]
name=start
{SUCCEED}
[/event]
)}
#####
# API(s) being tested: [elseif][return]
##

View file

@ -337,7 +337,9 @@
0 check_interrupts_return
0 check_interrupts_continue
0 check_interrupts_break_global
0 check_interrupts_return_nested
0 check_interrupts_break_nested_event
0 check_interrupts_return_nested_command
0 check_interrupts_return_nested_event
9 check_interrupts_continue_global
0 check_interrupts_elseif
0 check_interrupts_case