Files
Toy/test/scripts/lib/runner.toy

89 lines
1.4 KiB
Plaintext

import runner;
//test basic loading and freeing of a script file
{
var s = loadScript("scripts:/runner_sample_code.toy");
s.freeScript();
}
//test basic loading and freeing of a binary file
{
var s = loadScriptBytecode("scripts:/lib/runner/sample_bytecode.tb");
s.freeScript();
}
//test running an external script
{
var s = loadScript("scripts:/runner_sample_code.toy");
s.runScript();
s.freeScript();
}
//test running an external binary file
{
var s = loadScriptBytecode("scripts:/lib/runner/sample_bytecode.tb");
s.runScript();
s.freeScript();
}
//test resetting an external script
{
var s = loadScript("scripts:/runner_sample_code.toy");
s.runScript();
s.resetScript();
assert !s.checkScriptDirty(), "checkScriptDirty failed";
s.runScript();
assert s.checkScriptDirty(), "_checkScriptDirty() failed";
s.resetScript();
s.runScript();
s.freeScript();
}
//test running a nested external script
{
var s = loadScript("scripts:/lib/runner/sample_1.toy");
s.runScript();
s.freeScript();
}
//test retrieving a script variable
{
var s = loadScript("scripts:/runner_sample_code.toy");
s.runScript();
var fib = s.getScriptVar("fib");
assert fib(12) == 144, "_getScriptVar() failed";
s.freeScript();
}
//test calling a script function
{
var s = loadScript("scripts:/runner_sample_code.toy");
s.runScript();
assert s.callScriptFn("fib", 12) == 144, "_callScriptFn() failed";
s.freeScript();
}
print "All good";