From 7df34d498d1df456cdcdcb28681616794c9549ce Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 3 Nov 2023 16:02:27 +0100 Subject: QmlCompiler: Retrieve original types for comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an original type is merely wrapped into a more generic type by the basic blocks pass, we know the original data is still there and can be used for comparison. Fixes: QTBUG-117795 Change-Id: Ia7582cd8ed48e47a3a1b3bd8e2595e9cb42828de Reviewed-by: Qt CI Bot Reviewed-by: Olivier De Cannière Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp') diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 3f0e2a4569..37f874ba91 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -59,6 +59,7 @@ private slots: void callWithSpread(); void colorAsVariant(); void colorString(); + void compareOriginals(); void comparisonTypes(); void componentReturnType(); void compositeSingleton(); @@ -967,6 +968,18 @@ void tst_QmlCppCodegen::colorString() QCOMPARE(qvariant_cast(rootObject->property("e")), QColor::fromRgb(0x11, 0x22, 0x33)); } +void tst_QmlCppCodegen::compareOriginals() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/compareOriginals.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QCOMPARE(object->property("compareOriginals").toInt(), 5); + QVERIFY(object->property("optionalThis").toBool()); +} + void tst_QmlCppCodegen::comparisonTypes() { QQmlEngine engine; -- cgit v1.2.3