Add Quat tests, for debugging a problem

This commit is contained in:
Dale Glass 2023-03-10 16:43:49 +01:00 committed by ksuprynowicz
parent 4d8a20aed7
commit d8488859e2
2 changed files with 32 additions and 1 deletions

View file

@ -302,6 +302,37 @@ void ScriptEngineTests::testSignalWithException() {
QVERIFY(exceptionCount >= 3);
}
void ScriptEngineTests::testQuat() {
QString script =
"var x;\n"
"print(JSON.stringify(Quat.IDENTITY));\n"
"print(JSON.stringify(Quat.safeEulerAngles(Quat.IDENTITY)));\n"
"print(JSON.stringify(Quat.getUp(Quat.IDENTITY)));\n"
"print(JSON.stringify(Quat.getUp(x)));\n"
"Script.stop(true);\n";
int printCount = 0;
QStringList answers{
"{\"x\":0,\"y\":0,\"z\":0,\"w\":1}",
"{\"x\":0,\"y\":0,\"z\":0}",
"{\"x\":0,\"y\":1,\"z\":0}",
""
};
auto sm = makeManager(script, "testQuat.js");
connect(sm.get(), &ScriptManager::printedMessage, [&printCount, answers](const QString& message, const QString& engineName){
QCOMPARE(message, answers[printCount++]);
});
connect(sm.get(), &ScriptManager::unhandledException, [](std::shared_ptr<ScriptException> exception){
QVERIFY(exception->errorMessage.contains("undefined to glm::quat"));
});
sm->run();
}
void ScriptEngineTests::scriptTest() {
return;

View file

@ -65,7 +65,7 @@ private slots:
void testRaiseExceptionAndCatch();
void testSignal();
void testSignalWithException();
void testQuat();
private: