Showing the changes to tests/script-engine/src/ScriptEngineTests.cpp (1 of 2 files). Show all
Unified · Split
| @@ -302,6 +302,37 @@ void ScriptEngineTests::testSignalWithException() { · 301 unmodified lines | ||
| 302 | 302 | QVERIFY(exceptionCount >= 3); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | +void 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 | |
| 306 | 337 | void ScriptEngineTests::scriptTest() { |
| 307 | 338 | return; |