aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-09-04 10:25:37 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-10-11 14:40:18 +0000
commita4852b1ee77a913f6cc4806e6606c1b720e8f40b (patch)
treeac430430bf167465153485974e31fb4d9f723e75 /tests
parentb6f7fe1f80e6beed62ef47691fae6aa9f4a851b8 (diff)
Fix error reporting when imports or re-exports in modules fail
Collect the location of the import/export statement and include it in the exception thrown. Change-Id: I7966dfd53ed67d2d7087acde2dd8ff67c64cb044 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/exporterror1.mjs2
-rw-r--r--tests/auto/qml/qjsengine/importerror1.mjs2
-rw-r--r--tests/auto/qml/qjsengine/qjsengine.pro2
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp17
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"