History

Initial implementation of raiseException and test

Dale Glass committed 3 years ago

Commit 8f827501 parent 03699493 files · +60 −22Browse files

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

Unified · Split

tests/script-engine/src/ScriptEngineTests.cpp+29−0
@@ -218,6 +218,35 @@ void ScriptEngineTests::testRaiseException() { · 217 unmodified lines
218 QVERIFY(ex && ex->errorMessage.contains("Exception test"));218 QVERIFY(ex && ex->errorMessage.contains("Exception test"));
219}219}
220 220
221void ScriptEngineTests::testRaiseExceptionAndCatch() {
222 QString script =
223 "try {"
224 " testClass.doRaiseTest();"
225 "} catch (err) {"
226 " if (err === \"Exception test!\") {"
227 " print(\"Caught!\");"
228 " }"
229 "}"
230 "Script.stop(true);"
231 ;
232
233 QString printed;
234 auto sm = makeManager(script, "testRaiseCatch.js");
235
236 connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){
237 printed.append(message);
238 });
239
240
241 sm->engine()->registerGlobalObject("testClass", new TestClass(sm->engine()));
242
243 sm->run();
244 auto ex = sm->getUncaughtException();
245
246 QVERIFY(!ex);
247 QVERIFY(printed == "Caught!");
248}
249
221 250
222void ScriptEngineTests::scriptTest() {251void ScriptEngineTests::scriptTest() {
223 return;252 return;