History

Add Quat tests, for debugging a problem

Dale Glass committed 3 years ago

Commit d8488851 parent 4d8a20a2 files · +32 −1Browse files

Showing the changes to tests/script-engine/src/ScriptEngineTests.cpp (1 of 2 files). Show all

Unified · Split

tests/script-engine/src/ScriptEngineTests.cpp+31−0
@@ -302,6 +302,37 @@ void ScriptEngineTests::testSignalWithException() { · 301 unmodified lines
302 QVERIFY(exceptionCount >= 3);302 QVERIFY(exceptionCount >= 3);
303}303}
304 304
305void ScriptEngineTests::testQuat() {
306 QString script =
307 "var x;\n"
308 "print(JSON.stringify(Quat.IDENTITY));\n"
309 "print(JSON.stringify(Quat.safeEulerAngles(Quat.IDENTITY)));\n"
310 "print(JSON.stringify(Quat.getUp(Quat.IDENTITY)));\n"
311 "print(JSON.stringify(Quat.getUp(x)));\n"
312 "Script.stop(true);\n";
313
314 int printCount = 0;
315 QStringList answers{
316 "{\"x\":0,\"y\":0,\"z\":0,\"w\":1}",
317 "{\"x\":0,\"y\":0,\"z\":0}",
318 "{\"x\":0,\"y\":1,\"z\":0}",
319 ""
320 };
321
322 auto sm = makeManager(script, "testQuat.js");
323
324 connect(sm.get(), &ScriptManager::printedMessage, [&printCount, answers](const QString& message, const QString& engineName){
325 QCOMPARE(message, answers[printCount++]);
326 });
327
328 connect(sm.get(), &ScriptManager::unhandledException, [](std::shared_ptr<ScriptException> exception){
329 QVERIFY(exception->errorMessage.contains("undefined to glm::quat"));
330 });
331
332
333 sm->run();
334}
335
305 336
306void ScriptEngineTests::scriptTest() {337void ScriptEngineTests::scriptTest() {
307 return;338 return;