mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 06:40:07 +00:00
78 lines
1.1 KiB
INI
78 lines
1.1 KiB
INI
{GENERIC_UNIT_TEST "test_wml_actions" (
|
|
[event]
|
|
name = start
|
|
[lua]
|
|
code = <<
|
|
function wesnoth.wml_actions.foo(cfg)
|
|
if cfg.bar then
|
|
wesnoth.set_variable("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]
|
|
)}
|