diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-09-28 14:02:04 +0200 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2018-10-22 15:05:29 +0000 |
commit | 1ac3dd0e7adbca0e18daac10ef5e104ca1e5fe87 (patch) | |
tree | 6325a12545fc764a5967ebcdcc733302f248a18e /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | f8ee8e4e8b3051ffd63533017f6b647fef6056ff (diff) |
Add test for importing let/const variables from scripts
Try to import let/const variables from JS scripts into QML.
Task-number: QTBUG-69408
Change-Id: Ie58cbc8cd9f8a47f5a077f95b07b5f9e1524707a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index cf3eecff6d..8f388fcac6 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -357,6 +357,8 @@ private slots: void jumpStrictNotEqualUndefined(); void removeBindingsWithNoDependencies(); void temporaryDeadZone(); + void importLexicalVariables_data(); + void importLexicalVariables(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8812,6 +8814,38 @@ void tst_qqmlecmascript::temporaryDeadZone() QVERIFY(v.isError()); } +void tst_qqmlecmascript::importLexicalVariables_data() +{ + QTest::addColumn<QUrl>("testFile"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("script") + << testFileUrl("importLexicalVariables_script.qml") + << QStringLiteral("0?? 1?? 2??"); + QTest::newRow("pragmaLibrary") + << testFileUrl("importLexicalVariables_pragmaLibrary.qml") + << QStringLiteral("0?? 1?? 2??"); + QTest::newRow("module") + << testFileUrl("importLexicalVariables_module.qml") + << QStringLiteral("000 000 110"); +} + +void tst_qqmlecmascript::importLexicalVariables() +{ + QFETCH(QUrl, testFile); + QFETCH(QString, expected); + + QQmlEngine engine; + QQmlComponent component(&engine, testFile); + QScopedPointer<QObject> object(component.create()); + QVERIFY(object != nullptr); + QVERIFY(!component.isError()); + + QVariant result; + QMetaObject::invokeMethod(object.data(), "runTest", Qt::DirectConnection, Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result, QVariant(expected)); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |