History

Add missing scope guards in script engine tests

Dale Glass committed 6 months ago

Commit 95f600f1 parent c249d712 files · +16 −5Browse 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+9−5
@@ -30,11 +30,6 @@ · 29 unmodified lines
3030
3131 QTEST_MAIN(ScriptEngineTests)
3232
33−
34−
35−
36−
37−
3833 void ScriptEngineTests::initTestCase() {
3934 // AudioClient starts networking, but for the purposes of the tests here we don't care,
4035 // so just got to use some port.
@@ -102,6 +97,8 @@ ScriptManagerPointer ScriptEngineTests::makeManager(const QString &scriptSource, · 61 unmodified lines
10297
10398 void ScriptEngineTests::testTrivial() {
10499 auto sm = makeManager("print(\"script works!\"); Script.stop(true);", "testTrivial.js");
100+ auto scopeGuard = sm->engine()->getScopeGuard();
101+
105102 QString printed;
106103
107104 QVERIFY(!sm->isRunning());
@@ -125,6 +122,8 @@ void ScriptEngineTests::testTrivial() { · 17 unmodified lines
125122
126123 void ScriptEngineTests::testSyntaxError() {
127124 auto sm = makeManager("this is not good syntax", "testSyntaxError.js");
125+ auto scopeGuard = sm->engine()->getScopeGuard();
126+
128127 bool exceptionHappened = false;
129128
130129 connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){
@@ -146,6 +145,7 @@ void ScriptEngineTests::testSyntaxError() { · 15 unmodified lines
146145
147146 void ScriptEngineTests::testRuntimeError() {
148147 auto sm = makeManager("nonexisting();", "testRuntimeError.js");
148+ auto scopeGuard = sm->engine()->getScopeGuard();
149149 bool exceptionHappened = false;
150150
151151 connect(sm.get(), &ScriptManager::unhandledException, [&exceptionHappened](std::shared_ptr<ScriptException> exception){
@@ -167,6 +167,7 @@ void ScriptEngineTests::testRuntimeError() { · 15 unmodified lines
167167
168168 void ScriptEngineTests::testJSThrow() {
169169 auto sm = makeManager("throw(42);", "testThrow.js");
170+ auto scopeGuard = sm->engine()->getScopeGuard();
170171 sm->run();
171172
172173 std::shared_ptr<ScriptException> ex = sm->getUncaughtException();
@@ -266,6 +267,7 @@ void ScriptEngineTests::testSignal() { · 93 unmodified lines
266267
267268 QStringList printed;
268269 auto sm = makeManager(script, "testSignal.js");
270+ auto scopeGuard = sm->engine()->getScopeGuard();
269271
270272 connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){
271273 printed.append(message);
@@ -291,6 +293,7 @@ void ScriptEngineTests::testSignalWithException() { · 19 unmodified lines
291293 int exceptionCount = 0;
292294
293295 auto sm = makeManager(script, "testSignalWithException.js");
296+ auto scopeGuard = sm->engine()->getScopeGuard();
294297
295298 connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){
296299 printed.append(message);
@@ -324,6 +327,7 @@ void ScriptEngineTests::testQuat() { · 27 unmodified lines
324327 };
325328
326329 auto sm = makeManager(script, "testQuat.js");
330+ auto scopeGuard = sm->engine()->getScopeGuard();
327331
328332 connect(sm.get(), &ScriptManager::printedMessage, [&printCount, answers](const QString& message, const QString& engineName){
329333 QCOMPARE(message, answers[printCount++]);