Rework of evaluation variable handling, to account for functions having branching variable states
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-08 18:33:56 +02:00
parent 4d452b33e0
commit 471632c6e4
4 changed files with 57 additions and 13 deletions

View File

@@ -104,4 +104,33 @@ TEST_CASE( "Functions can call themselves", "[integration]" ) {
delete script;
}
TEST_CASE( "Functions respect scope", "[integration]" ) {
Script* script = Script::Create(
R"(
function test()
function foo()
local a = 10
end
if true then
if true then
local a = 50
foo()
result = a
end
end
end
test()
)"
);
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto variable = script->GetVariable("result");
REQUIRE(variable->GetType()->GetClass() == TypeClass::Number);
REQUIRE(variable->EvaluateInteger() == 50);
delete script;
}
#endif