aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-02-04 08:31:10 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-02-04 12:46:48 +0100
commita8bc011d459a4d080815a2675f2a0413c8bf09d2 (patch)
treeb1ce28a37ccff86543ff6595bb5ab6be47f8ca7f /tests
parentac46c9f6ce9ef757e0ccba8a283cb0efabaef56e (diff)
QV4: Handle value tyes in sameValue algorithm
The sameValue(Zero) algorithm were implemented according to the JavaScript specification; however QML has the concept of value types. For those we need to check equality with the intrinsic isEqualTo method. This aligns sameValue(Zero) with strict equality in its treatment of value types. This fixes Array.includes for value types Fixes: QTBUG-81825 Change-Id: Idd3e09cbed94bca6ea44f5683610b87d184e432c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index ec0db16114..558647e17a 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -74,6 +74,7 @@ public:
private slots:
void initTestCase();
+ void arrayIncludesValueType();
void assignBasicTypes();
void assignDate_data();
void assignDate();
@@ -414,6 +415,36 @@ void tst_qqmlecmascript::initTestCase()
registerTypes();
}
+void tst_qqmlecmascript::arrayIncludesValueType()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ // It is vital that QtQuick is imported below else we get a warning about
+ // QQml_colorProvider and tst_qqmlecmascript::signalParameterTypes fails due
+ // to some static variable being initialized with the wrong value
+ component.setData(R"(
+ import QtQuick 2.15
+ import QtQml 2.15
+ QtObject {
+ id: root
+ property color r: Qt.rgba(1, 0, 0)
+ property color g: Qt.rgba(0, 1, 0)
+ property color b: Qt.rgba(0, 0, 1)
+ property var colors: [r, g, b]
+ property bool success: false
+
+ Component.onCompleted: {
+ root.success = root.colors.includes(root.g)
+ }
+ }
+ )", QUrl("testData"));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(o);
+ auto success = o->property("success");
+ QVERIFY(success.isValid());
+ QVERIFY(success.toBool());
+}
+
void tst_qqmlecmascript::assignBasicTypes()
{
QQmlEngine engine;