wesnoth/data/test/scenarios/test_lua_wml.cfg
mattsc 0e017d9f7c Lua code: replace deprecated wesnoth.set_variable() calls
(cherry-picked from commit ce7faae4f41f23f1d1f61d2b4f5ca95d4ce4f89a)
2018-10-07 03:21:07 +00:00

78 lines
1.2 KiB
INI

{GENERIC_UNIT_TEST "test_wml_actions" (
[event]
name = start
[lua]
code = <<
function wesnoth.wml_actions.foo(cfg)
if cfg.bar then
wml.variables["result"] = cfg.bar
end
end
>>
[/lua]
{VARIABLE result 0}
{ASSERT {VARIABLE_CONDITIONAL result equals 0}}
[foo]
bar = 1
[/foo]
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
[foo]
baz = 0
[/foo]
{ASSERT {VARIABLE_CONDITIONAL result equals "1"}}
[foo]
bar = 2
[/foo]
{RETURN {VARIABLE_CONDITIONAL result equals "2"}}
[/event]
)}
{GENERIC_UNIT_TEST "test_wml_conditionals" (
[event]
name = start
[lua]
code = <<
function wesnoth.wml_conditionals.foo(cfg)
return (cfg.bar == "baz")
end
>>
[/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])}
{SUCCEED}
[/event]
)}