Allow non-local script functions to be called from outside the script
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user