Support "next" statement, skipping the remainder of the loop block.
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user