Showing the changes to tests/script-engine/src/ScriptEngineTests.cpp (1 of 2 files). Show all
Unified · Split
| @@ -30,11 +30,6 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | QTEST_MAIN(ScriptEngineTests) | 31 | QTEST_MAIN(ScriptEngineTests) |
| 32 | 32 | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | void ScriptEngineTests::initTestCase() { | 33 | void ScriptEngineTests::initTestCase() { |
| 39 | // AudioClient starts networking, but for the purposes of the tests here we don't care, | 34 | // AudioClient starts networking, but for the purposes of the tests here we don't care, |
| 40 | // so just got to use some port. | 35 | // so just got to use some port. |
| @@ -102,6 +97,8 @@ ScriptManagerPointer ScriptEngineTests::makeManager(const QString &scriptSource, · 61 unmodified lines | |||
| 102 | 97 | ||
| 103 | void ScriptEngineTests::testTrivial() { | 98 | void ScriptEngineTests::testTrivial() { |
| 104 | auto sm = makeManager("print(\"script works!\"); Script.stop(true);", "testTrivial.js"); | 99 | auto sm = makeManager("print(\"script works!\"); Script.stop(true);", "testTrivial.js"); |
| 100 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 101 | |||
| 105 | QString printed; | 102 | QString printed; |
| 106 | 103 | ||
| 107 | QVERIFY(!sm->isRunning()); | 104 | QVERIFY(!sm->isRunning()); |
| @@ -125,6 +122,8 @@ void ScriptEngineTests::testTrivial() { · 17 unmodified lines | |||
| 125 | 122 | ||
| 126 | void ScriptEngineTests::testSyntaxError() { | 123 | void ScriptEngineTests::testSyntaxError() { |
| 127 | auto sm = makeManager("this is not good syntax", "testSyntaxError.js"); | 124 | auto sm = makeManager("this is not good syntax", "testSyntaxError.js"); |
| 125 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 126 | |||
| 128 | bool exceptionHappened = false; | 127 | bool exceptionHappened = false; |
| 129 | 128 | ||
| 130 | connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){ | 129 | connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){ |
| @@ -146,6 +145,7 @@ void ScriptEngineTests::testSyntaxError() { · 15 unmodified lines | |||
| 146 | 145 | ||
| 147 | void ScriptEngineTests::testRuntimeError() { | 146 | void ScriptEngineTests::testRuntimeError() { |
| 148 | auto sm = makeManager("nonexisting();", "testRuntimeError.js"); | 147 | auto sm = makeManager("nonexisting();", "testRuntimeError.js"); |
| 148 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 149 | bool exceptionHappened = false; | 149 | bool exceptionHappened = false; |
| 150 | 150 | ||
| 151 | connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){ | 151 | connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){ |
| @@ -167,6 +167,7 @@ void ScriptEngineTests::testRuntimeError() { · 15 unmodified lines | |||
| 167 | 167 | ||
| 168 | void ScriptEngineTests::testJSThrow() { | 168 | void ScriptEngineTests::testJSThrow() { |
| 169 | auto sm = makeManager("throw(42);", "testThrow.js"); | 169 | auto sm = makeManager("throw(42);", "testThrow.js"); |
| 170 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 170 | sm->run(); | 171 | sm->run(); |
| 171 | 172 | ||
| 172 | std::shared_ptr<ScriptException> ex = sm->getUncaughtException(); | 173 | std::shared_ptr<ScriptException> ex = sm->getUncaughtException(); |
| @@ -266,6 +267,7 @@ void ScriptEngineTests::testSignal() { · 93 unmodified lines | |||
| 266 | 267 | ||
| 267 | QStringList printed; | 268 | QStringList printed; |
| 268 | auto sm = makeManager(script, "testSignal.js"); | 269 | auto sm = makeManager(script, "testSignal.js"); |
| 270 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 269 | 271 | ||
| 270 | connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | 272 | connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ |
| 271 | printed.append(message); | 273 | printed.append(message); |
| @@ -291,6 +293,7 @@ void ScriptEngineTests::testSignalWithException() { · 19 unmodified lines | |||
| 291 | int exceptionCount = 0; | 293 | int exceptionCount = 0; |
| 292 | 294 | ||
| 293 | auto sm = makeManager(script, "testSignalWithException.js"); | 295 | auto sm = makeManager(script, "testSignalWithException.js"); |
| 296 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 294 | 297 | ||
| 295 | connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | 298 | connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ |
| 296 | printed.append(message); | 299 | printed.append(message); |
| @@ -324,6 +327,7 @@ void ScriptEngineTests::testQuat() { · 27 unmodified lines | |||
| 324 | }; | 327 | }; |
| 325 | 328 | ||
| 326 | auto sm = makeManager(script, "testQuat.js"); | 329 | auto sm = makeManager(script, "testQuat.js"); |
| 330 | auto scopeGuard = sm->engine()->getScopeGuard(); | ||
| 327 | 331 | ||
| 328 | connect(sm.get(), &ScriptManager::printedMessage, [&printCount, answers](const QString& message, const QString& engineName){ | 332 | connect(sm.get(), &ScriptManager::printedMessage, [&printCount, answers](const QString& message, const QString& engineName){ |
| 329 | QCOMPARE(message, answers[printCount++]); | 333 | QCOMPARE(message, answers[printCount++]); |