diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index fedcd477a0..3f0e2a4569 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -165,6 +165,7 @@ private slots: void objectToString(); void objectWithStringListMethod(); void onAssignment(); + void optionalComparison(); void outOfBoundsArray(); void overriddenProperty(); void ownPropertiesNonShadowable(); @@ -3365,6 +3366,27 @@ void tst_QmlCppCodegen::onAssignment() QCOMPARE(object->property("scale").toDouble(), 1.0); } +void tst_QmlCppCodegen::optionalComparison() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/optionalComparison.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QCOMPARE(object->property("found").toInt(), 1); + QCOMPARE(object->property("foundStrict").toInt(), 1); + QCOMPARE(object->property("foundNot").toInt(), 2); + QCOMPARE(object->property("foundStrictNot").toInt(), 2); + + // this === this, null === null (x4), undefined === undefined + QCOMPARE(object->property("undefinedEqualsUndefined").toInt(), 6); + + QCOMPARE(object->property("optionalNull").toBool(), true); + object->setObjectName("foo"_L1); + QCOMPARE(object->property("optionalNull").toBool(), false); +} + void tst_QmlCppCodegen::outOfBoundsArray() { QQmlEngine engine; |
