Fixes for setting to tables not working properly
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-09-22 15:20:22 +02:00
parent 62be1c78f3
commit 256244eabb
5 changed files with 53 additions and 11 deletions

View File

@@ -184,5 +184,22 @@ end
delete runCount;
}
TEST_CASE( "Generic for loop next", "[integration]" ) {
auto script = Script::Create(uR"(
local table = {1, 3, 5, 7, 9}
result = 0
for i,v in table do
if i == 3 then next end
result = result + v
end
)");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto var = script->GetVariable(u"result");
REQUIRE(var->EvaluateInteger() == 20);
delete script;
delete var;
}
#endif

View File

@@ -111,6 +111,24 @@ return table[1]
delete script;
}
TEST_CASE( "assign nil to a string table", "[integration]" ) {
Script* script = Script::Create(
R"(
table = {'bla', 'test', 'foo', 'bar'}
table[3] = nil
return table
)");
REQUIRE(!script->Diagnostics -> HasErrors());
auto variable = script->Evaluate();
REQUIRE(variable.Get() != nullptr);
auto lookup = Utilities::HashedString::CreateLookup(3);
auto tableValue = variable->IndexValue(&lookup);
REQUIRE(tableValue->GetTypeClass() == TypeClass::Nil);
delete script;
delete tableValue;
}
#endif