Make functions be able to call themselves
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -84,5 +84,24 @@ TEST_CASE( "Define script function and return", "[integration]" ) {
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Functions can call themselves", "[integration]" ) {
|
||||
Script* script = Script::Create(
|
||||
"val = 0\n"
|
||||
"function add() \n"
|
||||
"if val < 5 then\n"
|
||||
"val = val + 1\n"
|
||||
"add()\n"
|
||||
"end\n"
|
||||
"end");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
script->Evaluate();
|
||||
script->CallFunction("add", {});
|
||||
|
||||
auto variable = script->GetVariable("val");
|
||||
REQUIRE(variable->GetType()->GetClass() == TypeClass::Number);
|
||||
REQUIRE(variable->EvaluateInteger() == 5);
|
||||
|
||||
delete script;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user