Fixes for setting to tables not working properly
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user