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