Allow non-local script functions to be called from outside the script

This commit is contained in:
2019-06-05 18:44:23 +02:00
parent 43dede9ae2
commit bda26b0ddf
6 changed files with 50 additions and 4 deletions

View File

@@ -1,3 +0,0 @@

View File

@@ -38,4 +38,20 @@ TEST_CASE( "Define script function and call multiple times", "[integration]" ) {
delete script;
}
TEST_CASE( "Define script function and call from extern", "[integration]" ) {
Script* script = Script::Create("result = 0 function add(number a) result = result + a end");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
REQUIRE(script->HasFunction("add"));
script->CallFunction("add", {new IntegerEvalValue(5)});
script->CallFunction("add", {new IntegerEvalValue(6)});
auto result = script->GetVariable("result");
REQUIRE(result->GetType()->GetClass() == TypeClass::Number);
REQUIRE(result->EvaluateInteger() == 11);
delete script;
}
#endif