mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 18:31:32 +00:00

This doesn't cover all of the unit tests, it's the result of running wmlindent on all of them and then reviewing whether the changes were bugs in the test, or whether they're bugs in wmlindent. Note: there are two cve_2018_1999023 tests. The other one needs to be treated as a binary file, but the one changed here is plain text that loads its attack from a separate file. The change in start_position_generic.cfg doesn't seem good, but it's not particularly bad and it's what wmlindent currently does.
40 lines
1.2 KiB
INI
40 lines
1.2 KiB
INI
#####
|
|
# API(s) being tested: wml_utils.scoped_var
|
|
##
|
|
# Actions:
|
|
# Set test_var to 1.
|
|
# Declare a scoped variable of test_var.
|
|
# Set test_var to 5.
|
|
##
|
|
# Expected end state:
|
|
# After the scoped variable is declared, test_var has no assigned value.
|
|
# After the scope of the scoped variable ends, test_var's value is back to being 1 rather than 5.
|
|
#####
|
|
{GENERIC_UNIT_TEST "test_scoped_vars" (
|
|
[event]
|
|
name = prestart
|
|
{VARIABLE test_var 1}
|
|
#[inspect][/inspect]
|
|
{ASSERT {VARIABLE_CONDITIONAL test_var equals 1}}
|
|
[lua]
|
|
code = <<
|
|
local wml_utils = wesnoth.require "wml-utils"
|
|
local var <close> = wml_utils.scoped_var("test_var")
|
|
-- This runs the contents of [args] as WML actions
|
|
wml_utils.handle_event_commands(...)
|
|
>>
|
|
[args]
|
|
#[inspect][/inspect]
|
|
{ASSERT {VARIABLE_CONDITIONAL test_var equals ""}}
|
|
{VARIABLE test_var 5}
|
|
#[inspect][/inspect]
|
|
{ASSERT {VARIABLE_CONDITIONAL test_var equals 5}}
|
|
[/args]
|
|
[/lua]
|
|
|
|
#[inspect][/inspect]
|
|
{ASSERT {VARIABLE_CONDITIONAL test_var equals 1}}
|
|
{SUCCEED}
|
|
[/event]
|
|
)}
|