diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-18 11:40:10 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-23 10:27:48 +0100 |
| commit | bce216d5c086a5aa8f88d13933eeccebca316359 (patch) | |
| tree | 9b81d9868498872382ba2c0e78a3d74c1c745e76 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | dca259f040cfa452f5b617fe0112dcd70fe2c5fd (diff) | |
QmlCompiler: Fix comparison of null and undefined
Those are not stored. If we compare null to null or undefined to
undefined, we do not have to generate a comparison at all. the result is
statically known.
Pick-to: 6.4
Fixes: QTBUG-108634
Change-Id: I6a5323c2e0c023838609aec90d7ecc15b885dc08
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index dd8338e8fd..7278ea70bb 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -145,6 +145,7 @@ private slots: void letAndConst(); void signalIndexMismatch(); void callWithSpread(); + void nullComparison(); }; void tst_QmlCppCodegen::initTestCase() @@ -2802,6 +2803,21 @@ void tst_QmlCppCodegen::callWithSpread() QTest::ignoreMessage(QtCriticalMsg, "That is great!"); QScopedPointer<QObject> o(c.create()); QVERIFY(!o.isNull()); +} + +void tst_QmlCppCodegen::nullComparison() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/nullComparison.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QCOMPARE(o->property("v").toInt(), 1); + QCOMPARE(o->property("w").toInt(), 3); + QCOMPARE(o->property("x").toInt(), 1); + QCOMPARE(o->property("y").toInt(), 5); }; QTEST_MAIN(tst_QmlCppCodegen) |
