aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllanguage/data/thisInArrow.qml39
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp25
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/thisInArrow.qml b/tests/auto/qml/qqmllanguage/data/thisInArrow.qml
new file mode 100644
index 0000000000..7dd19782e6
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/thisInArrow.qml
@@ -0,0 +1,39 @@
+import QtQml
+
+QtObject {
+ id: root
+
+ property int width: 43
+ Component.onCompleted: () => { console.log(this.width); }
+
+ property var arrow: () => { return this; }
+ property var func: function() { return this; }
+
+ property QtObject child: QtObject {
+ property var aa;
+ property var ff;
+
+ Component.onCompleted: {
+ root.arrowResult = root.arrow();
+ root.funcResult = root.func();
+
+ var a = root.arrow;
+ root.aResult = a();
+ var f = root.func;
+ root.fResult = f();
+
+ aa = a;
+ root.aaResult = aa();
+
+ ff = f;
+ root.ffResult = ff();
+ }
+ }
+
+ property var arrowResult
+ property var funcResult
+ property var aResult
+ property var fResult
+ property var aaResult
+ property var ffResult
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index d09f903ccb..bf7953c51c 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -364,6 +364,7 @@ private slots:
void propertyObserverOnReadonly();
void variantListConversion();
+ void thisInArrowFunction();
private:
QQmlEngine engine;
@@ -6372,6 +6373,30 @@ void tst_qqmllanguage::variantListConversion()
QCOMPARE(l1.a, 13ull);
}
+void tst_qqmllanguage::thisInArrowFunction()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("thisInArrow.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QTest::ignoreMessage(QtDebugMsg, "43");
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+
+ QCOMPARE(qvariant_cast<QObject *>(o->property("arrowResult")), o.data());
+ QCOMPARE(qvariant_cast<QObject *>(o->property("funcResult")), o.data());
+ QCOMPARE(qvariant_cast<QObject *>(o->property("aResult")), o.data());
+ QCOMPARE(qvariant_cast<QObject *>(o->property("aaResult")), o.data());
+
+ QCOMPARE(qvariant_cast<QObject *>(o->property("fResult")), nullptr);
+ QCOMPARE(o->property("fResult").metaType(), QMetaType::fromType<QJSValue>());
+ QVERIFY(qvariant_cast<QJSValue>(o->property("fResult")).isObject());
+
+ QObject *child = qvariant_cast<QObject *>(o->property("child"));
+ QVERIFY(child != nullptr);
+ QCOMPARE(qvariant_cast<QObject *>(o->property("ffResult")), child);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"