diff options
Diffstat (limited to 'tests/auto/qml/qjsengine')
-rw-r--r-- | tests/auto/qml/qjsengine/exporterror1.mjs | 2 | ||||
-rw-r--r-- | tests/auto/qml/qjsengine/importerror1.mjs | 2 | ||||
-rw-r--r-- | tests/auto/qml/qjsengine/qjsengine.pro | 2 | ||||
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 17 |
4 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/qml/qjsengine/exporterror1.mjs b/tests/auto/qml/qjsengine/exporterror1.mjs new file mode 100644 index 0000000000..9ce9aa3b83 --- /dev/null +++ b/tests/auto/qml/qjsengine/exporterror1.mjs @@ -0,0 +1,2 @@ +let dummy = 0; +export { nothere } from "./testmodule.mjs"; diff --git a/tests/auto/qml/qjsengine/importerror1.mjs b/tests/auto/qml/qjsengine/importerror1.mjs new file mode 100644 index 0000000000..be33753c56 --- /dev/null +++ b/tests/auto/qml/qjsengine/importerror1.mjs @@ -0,0 +1,2 @@ +let dummy = 0; +import { nothere } from "./testmodule.mjs"; diff --git a/tests/auto/qml/qjsengine/qjsengine.pro b/tests/auto/qml/qjsengine/qjsengine.pro index 1fb2d55b31..b412e37727 100644 --- a/tests/auto/qml/qjsengine/qjsengine.pro +++ b/tests/auto/qml/qjsengine/qjsengine.pro @@ -4,6 +4,6 @@ QT += qml qml-private widgets testlib gui-private macx:CONFIG -= app_bundle SOURCES += tst_qjsengine.cpp RESOURCES += qjsengine.qrc -RESOURCES += testmodule.mjs modulewithlexicals.mjs +RESOURCES += testmodule.mjs modulewithlexicals.mjs importerror1.mjs exporterror1.mjs TESTDATA = script/* diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index be62908772..6bc0359483 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -227,6 +227,7 @@ private slots: void importModule(); void importModuleRelative(); void importModuleWithLexicallyScopedVars(); + void importExportErrors(); public: Q_INVOKABLE QJSValue throwingCppMethod(); @@ -4404,6 +4405,22 @@ void tst_QJSEngine::importModuleWithLexicallyScopedVars() QCOMPARE(ns.property("main").call().toInt(), 10); } +void tst_QJSEngine::importExportErrors() +{ + { + QJSEngine engine; + QJSValue result = engine.importModule(QStringLiteral(":/importerror1.mjs")); + QVERIFY(result.isError()); + QCOMPARE(result.property("lineNumber").toInt(), 2); + } + { + QJSEngine engine; + QJSValue result = engine.importModule(QStringLiteral(":/exporterror1.mjs")); + QVERIFY(result.isError()); + QCOMPARE(result.property("lineNumber").toInt(), 2); + } +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" |