mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
script fixes from latest merge and more tests
This commit is contained in:
parent
ada1c5a021
commit
838395840d
3 changed files with 58 additions and 4 deletions
|
|
@ -647,5 +647,58 @@ TEST(Script, Sugar_Syntax)
|
|||
ASSERT_EQ(valueSetArray.getInt(), 5);
|
||||
}
|
||||
|
||||
TEST(Script, InnerObjectTests)
|
||||
{
|
||||
ConsoleValue theObject = RunScript(R"(
|
||||
function a()
|
||||
{
|
||||
%obj = new SimObject(TheOuterObject)
|
||||
{
|
||||
innerObject = new SimObject(TheInnerObject)
|
||||
{
|
||||
testField = 123;
|
||||
position = "1 2 3";
|
||||
};
|
||||
};
|
||||
return %obj;
|
||||
}
|
||||
return a();
|
||||
)");
|
||||
|
||||
SimObject* outerObject = Sim::findObject("TheOuterObject");
|
||||
ASSERT_NE(outerObject, (SimObject*)NULL);
|
||||
if (outerObject)
|
||||
{
|
||||
ASSERT_EQ(theObject.getInt(), Sim::findObject("TheOuterObject")->getId());
|
||||
}
|
||||
ASSERT_NE(Sim::findObject("TheInnerObject"), (SimObject*)NULL);
|
||||
|
||||
ConsoleValue positionValue = RunScript(R"(
|
||||
function TheOuterObject::getInnerPosition(%this)
|
||||
{
|
||||
return %this.innerObject.position;
|
||||
}
|
||||
|
||||
function a()
|
||||
{
|
||||
%position = TheOuterObject.getInnerPosition();
|
||||
return %position.y;
|
||||
}
|
||||
return a();
|
||||
)");
|
||||
|
||||
ASSERT_EQ(positionValue.getInt(), 2);
|
||||
|
||||
ConsoleValue nestedFuncCall = RunScript(R"(
|
||||
function TheInnerObject::test(%this)
|
||||
{
|
||||
return %this.testField;
|
||||
}
|
||||
|
||||
return TheOuterObject.innerObject.test();
|
||||
)");
|
||||
|
||||
ASSERT_EQ(nestedFuncCall.getInt(), 123);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue