aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine/tst_qjsengine.cpp
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/auto/qml/qjsengine/tst_qjsengine.cpp
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/auto/qml/qjsengine/tst_qjsengine.cpp')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp17
1 files changed, 17 insertions, 0 deletions
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"