Showing the changes to tests/script-engine/src/ScriptEngineNetworkedTests.cpp (1 of 5 files). Show all
Unified · Split
| @@ -155,3 +155,35 @@ void ScriptEngineNetworkedTests::testRequire() { · 154 unmodified lines | ||
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | |
| 158 | +void ScriptEngineNetworkedTests::testRequireInfinite() { | |
| 159 | + auto sm = makeManager( | |
| 160 | + "print(\"Starting\");" | |
| 161 | + "Script.require('./tests/require_inf_a.js');" | |
| 162 | + "print(\"Done\");" | |
| 163 | + "Script.stop(true);", "testRequireInf.js"); | |
| 164 | + QStringList printed; | |
| 165 | + QStringList expected {"Starting", "Value from A: 6", "Value from B: 6", "Done"}; | |
| 166 | + | |
| 167 | + | |
| 168 | + QVERIFY(!sm->isRunning()); | |
| 169 | + QVERIFY(!sm->isStopped()); | |
| 170 | + QVERIFY(!sm->isFinished()); | |
| 171 | + | |
| 172 | + connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | |
| 173 | + printed.append(message); | |
| 174 | + }); | |
| 175 | + | |
| 176 | + | |
| 177 | + qInfo() << "About to run script"; | |
| 178 | + sm->run(); | |
| 179 | + | |
| 180 | + QVERIFY(!sm->isRunning()); | |
| 181 | + QVERIFY(!sm->isStopped()); | |
| 182 | + QVERIFY(sm->isFinished()); | |
| 183 | + | |
| 184 | + QVERIFY(printed.length() == expected.length()); | |
| 185 | + for(int i=0;i<printed.length();i++) { | |
| 186 | + QString nomatch = QString("Result '%1' didn't match expected '%2'").arg(printed[i]).arg(expected[i]); | |
| 187 | + QVERIFY2(printed[i] == expected[i], qPrintable(nomatch)); | |
| 188 | + } | |
| 189 | +} | |