aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSemih Yavuz <semih.yavuz@qt.io>2023-01-30 22:33:00 +0100
committerSemih Yavuz <semih.yavuz@qt.io>2023-01-31 19:12:30 +0100
commit66bc0019684519e6ccf3c9910c1bbd9902a13911 (patch)
tree2acf3aa4b7a23d28beef35b85f4d77594dc3b492 /tests/auto
parentdb71a35b1e20b028e4e07c8229551fea8ac0eafb (diff)
qmlcachegen: fix nonstrict equality code generation
We should generate type checking code for only strict comparison of var against null/undefined types or vice versa cases. The non- strict comparison should be handled elsewhere. Removed pragma Strict to allow to add warning emitting tests of non-strict comparison. This amends 6a816a9e0dfc2b41a4f86c721679f2517ec27eb6 Pick-to: 6.5 Fixes: QTBUG-110769 Change-Id: I7f9a457e71a621a005f377216e841bec01667454 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/equalityVarAndNonStorable.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp5
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/equalityVarAndNonStorable.qml b/tests/auto/qml/qmlcppcodegen/data/equalityVarAndNonStorable.qml
index baf679aab2..7ab71940ee 100644
--- a/tests/auto/qml/qmlcppcodegen/data/equalityVarAndNonStorable.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/equalityVarAndNonStorable.qml
@@ -1,4 +1,3 @@
-pragma Strict
import QtQml
import TestTypes
@@ -33,4 +32,11 @@ QtObject {
property bool primitiveIsNull: wrapped.nullPrimitiveValue === null
property bool primitiveIsDefined: wrapped.intPrimitiveValue !== null && undefined !== wrapped.intPrimitiveValue
property bool primitiveIsUndefined: wrapped.undefinedPrimitiveValue === undefined
+
+ // Non-strict cases
+ property var nullVar: null
+ property bool nullVarIsUndefined: nullVar == undefined
+ property bool nullIsUndefined: null == undefined
+ property bool nullVarIsNull: nullVar == null
+ property bool nullIsNotUndefined: null !== undefined
}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 3db83ee884..400075c08d 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -3096,6 +3096,11 @@ void tst_QmlCppCodegen::equalityVarAndNonStorable()
QVERIFY(object->property("jsValueIsNull").toBool());
QVERIFY(object->property("jsValueIsDefined").toBool());
QVERIFY(object->property("jsValueIsUndefined").toBool());
+
+ QVERIFY(object->property("nullVarIsUndefined").toBool());
+ QVERIFY(object->property("nullIsUndefined").toBool());
+ QVERIFY(object->property("nullVarIsNull").toBool());
+ QVERIFY(object->property("nullIsNotUndefined").toBool());
};
void tst_QmlCppCodegen::equalityQObjects()