diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml | 28 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 51 |
3 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index efd95ce64f..29b272c440 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -151,6 +151,7 @@ set(qml_files detachedreferences.qml dialog.qml dialogButtonBox.qml + disappearingArrowFunction.qml dynamicscene.qml enforceSignature.qml enumConversion.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml b/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml new file mode 100644 index 0000000000..cb97ab5c02 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/disappearingArrowFunction.qml @@ -0,0 +1,28 @@ +pragma Strict +import QtQml + +QtObject { + property Person inner: Person { + function getName() : int { return 5 } + } + + property Person none: Person {} + + property Person evil: Person { + property string getName: "not a function" + } + + onObjectNameChanged: console.log(inner.getName()) + + function swapNone() { + let t = inner; + inner = none; + none = t; + } + + function swapEvil() { + let t = inner; + inner = evil; + evil = t; + } +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 579f279e93..5780862b47 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -103,6 +103,7 @@ private slots: void detachOnAssignment(); void detachedReferences(); void dialogButtonBox(); + void disappearingArrowFunction(); void enumConversion(); void enumFromBadSingleton(); void enumLookup(); @@ -1866,6 +1867,56 @@ void tst_QmlCppCodegen::dialogButtonBox() QPlatformDialogHelper::Ok | QPlatformDialogHelper::Cancel); } +void tst_QmlCppCodegen::disappearingArrowFunction() +{ + QQmlEngine engine; + const QUrl url(u"qrc:/qt/qml/TestTypes/disappearingArrowFunction.qml"_s); + QQmlComponent c(&engine, url); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QTest::ignoreMessage(QtDebugMsg, "5"); + o->setObjectName("no"); + + QMetaObject::invokeMethod(o.data(), "swapNone"); + QTest::ignoreMessage(QtDebugMsg, "Bart"); + o->setObjectName("nono"); + + QMetaObject::invokeMethod(o.data(), "swapNone"); + QTest::ignoreMessage(QtDebugMsg, "5"); + o->setObjectName("nonono"); + + const QRegularExpression warning( + QRegularExpression::escape(url.toString()) + + u"\\:15\\: TypeError\\: Property 'getName' of object " + "Person_QML_[0-9]+\\(0x[0-9a-f]+\\) is not a function"_s); + + QMetaObject::invokeMethod(o.data(), "swapEvil"); + QTest::ignoreMessage(QtWarningMsg, warning); + o->setObjectName("nononono"); + + QMetaObject::invokeMethod(o.data(), "swapEvil"); + QTest::ignoreMessage(QtDebugMsg, "5"); + o->setObjectName("nonononono"); + + QMetaObject::invokeMethod(o.data(), "swapNone"); + QTest::ignoreMessage(QtDebugMsg, "Bart"); + o->setObjectName("nononononono"); + + QMetaObject::invokeMethod(o.data(), "swapEvil"); + QTest::ignoreMessage(QtWarningMsg, warning); + o->setObjectName("nonononononono"); + + QMetaObject::invokeMethod(o.data(), "swapEvil"); + QTest::ignoreMessage(QtDebugMsg, "Bart"); + o->setObjectName("nononononononono"); + + QMetaObject::invokeMethod(o.data(), "swapNone"); + QTest::ignoreMessage(QtDebugMsg, "5"); + o->setObjectName("nonononononononono"); +} + void tst_QmlCppCodegen::enumConversion() { QQmlEngine engine; |
