Showing the changes to tests/script-engine/src/ScriptEngineTests.cpp (1 of 4 files). Show all
Unified · Split
| @@ -271,6 +271,37 @@ void ScriptEngineTests::testSignal() { · 270 unmodified lines | ||
| 271 | 271 | QVERIFY(printed.length() >= 10); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | +void ScriptEngineTests::testSignalWithException() { | |
| 275 | + QString script = | |
| 276 | + "var count = 0;" | |
| 277 | + "Script.update.connect(function(deltaTime) {" | |
| 278 | + " count++;" | |
| 279 | + " print(deltaTime);" | |
| 280 | + " if (count >= 3) {" | |
| 281 | + " Script.stop(true);" | |
| 282 | + " }" | |
| 283 | + " nonExist();" | |
| 284 | + "});"; | |
| 285 | + | |
| 286 | + QStringList printed; | |
| 287 | + int exceptionCount = 0; | |
| 288 | + | |
| 289 | + auto sm = makeManager(script, "testSignalWithException.js"); | |
| 290 | + | |
| 291 | + connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | |
| 292 | + printed.append(message); | |
| 293 | + }); | |
| 294 | + | |
| 295 | + connect(sm.get(), &ScriptManager::unhandledException, [&exceptionCount](std::shared_ptr<ScriptException> exception){ | |
| 296 | + exceptionCount++; | |
| 297 | + }); | |
| 298 | + | |
| 299 | + | |
| 300 | + sm->run(); | |
| 301 | + QVERIFY(printed.length() >= 3); | |
| 302 | + QVERIFY(exceptionCount >= 3); | |
| 303 | +} | |
| 304 | + | |
| 274 | 305 | |
| 275 | 306 | void ScriptEngineTests::scriptTest() { |
| 276 | 307 | return; |