mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Fix foreach over non-existant objects
This commit is contained in:
parent
f405666cbc
commit
c6047b24eb
2 changed files with 41 additions and 0 deletions
|
|
@ -540,6 +540,45 @@ TEST_F(ScriptTest, ForEachLoop)
|
|||
)");
|
||||
|
||||
ASSERT_EQ(forEachNestedReturn.getInt(), 42);
|
||||
|
||||
|
||||
ConsoleValue forEachNonExistantObject = RunScript(R"(
|
||||
$counter = 0;
|
||||
foreach ($obj in NonExistantSimSet)
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
)");
|
||||
|
||||
ASSERT_EQ(forEachNonExistantObject.getInt(), 0);
|
||||
|
||||
|
||||
ConsoleValue forEachOnZero = RunScript(R"(
|
||||
$counter = 0;
|
||||
foreach ($obj in 0)
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
)");
|
||||
|
||||
ASSERT_EQ(forEachOnZero.getInt(), 0);
|
||||
|
||||
|
||||
ConsoleValue forEachOnEmptyString = RunScript(R"(
|
||||
$counter = 0;
|
||||
foreach ($obj in "")
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
)");
|
||||
|
||||
ASSERT_EQ(forEachOnEmptyString.getInt(), 0);
|
||||
}
|
||||
|
||||
TEST_F(ScriptTest, TorqueScript_Array_Testing)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue