Rework of evaluation variable handling, to account for functions having branching variable states
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user