aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-09-20 10:48:33 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-09-23 20:27:40 +0000
commit6146021eb72a0aca5cc635b577b5e43b60824bc8 (patch)
treebbca3e8d57d763692a5418f19a587c2a01baf4d9 /tests/auto/qml/qjsengine/tst_qjsengine.cpp
parenta97d118bf55e1c44ded9bbcd143b0f0725db8268 (diff)
Fix use of lexically scoped variables in modules
Their use may trigger setting c->requiresExecutionContext on the module context, which is correct. However, unlike functions, modules at instantiation time always have their context created ahead of time (to populate imports). Therefore we must not emit call context creating byte code instructions where we'd end up storing exports in the wrong place. Change-Id: Id1264f1cfa6a7f1cd94247ffe71938bc9c5c3ff9 Fixes: QTBUG-70632 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.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index f08d9a4798..92696c7e76 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -226,6 +226,7 @@ private slots:
void importModule();
void importModuleRelative();
+ void importModuleWithLexicallyScopedVars();
public:
Q_INVOKABLE QJSValue throwingCppMethod();
@@ -4394,6 +4395,14 @@ void tst_QJSEngine::importModuleRelative()
}
}
+void tst_QJSEngine::importModuleWithLexicallyScopedVars()
+{
+ QJSEngine engine;
+ QJSValue ns = engine.importModule(QStringLiteral(":/modulewithlexicals.mjs"));
+ QVERIFY2(!ns.isError(), qPrintable(ns.toString()));
+ QCOMPARE(ns.property("main").call().toInt(), 10);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"