Support "next" statement, skipping the remainder of the loop block.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-09-22 13:49:37 +02:00
parent f4277d47c3
commit 2cd787c536
9 changed files with 70 additions and 7 deletions

View File

@@ -161,4 +161,28 @@ end
delete var;
}
TEST_CASE( "While loop next", "[integration]" ) {
auto script = Script::Create(uR"(
result = 0
runCount = 0
while true do
result = result + 1
if (result == 3) then next end
runCount = runCount + 1
if result >= 5 then break end
end
)");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto var = script->GetVariable(u"result");
REQUIRE(var->EvaluateInteger() == 5);
auto runCount = script->GetVariable(u"runCount");
REQUIRE(runCount->EvaluateInteger() == 4);
delete script;
delete var;
delete runCount;
}
#endif