aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/v4
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/v4')
-rw-r--r--tests/auto/qml/v4/data/equals.qml48
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.2.qml6
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.3.qml8
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.4.qml8
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.5.qml7
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.6.qml9
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.7.qml9
-rw-r--r--tests/auto/qml/v4/data/logicalAnd.qml6
-rw-r--r--tests/auto/qml/v4/data/nestedLogicalAnd.qml14
-rw-r--r--tests/auto/qml/v4/data/strictEquals.qml48
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp113
11 files changed, 276 insertions, 0 deletions
diff --git a/tests/auto/qml/v4/data/equals.qml b/tests/auto/qml/v4/data/equals.qml
new file mode 100644
index 0000000000..c32603cc7e
--- /dev/null
+++ b/tests/auto/qml/v4/data/equals.qml
@@ -0,0 +1,48 @@
+import QtQuick 2.0
+
+QtObject {
+ property QtObject myprop1: null
+ property QtObject myprop2: QtObject {}
+ property real zero: 0
+ property bool falseProp: false
+
+ property bool test1: myprop1 == false
+ property bool test2: myprop1 == null
+ property bool test3: 5 == myprop1
+ property bool test4: null == myprop1
+ property bool test5: myprop1 != false
+ property bool test6: myprop1 != null
+ property bool test7: 5 != myprop1
+ property bool test8: null != myprop1
+
+ property bool test9: myprop2 == false
+ property bool test10: myprop2 == null
+ property bool test11: 5 == myprop2
+ property bool test12: null == myprop2
+ property bool test13: myprop2 != false
+ property bool test14: myprop2 != null
+ property bool test15: 5 != myprop2
+ property bool test16: null != myprop2
+
+ property bool test17: myprop1 == myprop1
+ property bool test18: myprop1 != myprop1
+ property bool test19: myprop1 == myprop2
+ property bool test20: myprop1 != myprop2
+ property bool test21: myprop2 == myprop2
+ property bool test22: myprop2 != myprop2
+
+ property bool test23: myprop1 == "hello"
+ property bool test24: myprop1 != "hello"
+ property bool test25: myprop2 == "hello"
+ property bool test26: myprop2 != "hello"
+
+ property bool test27: falseProp == zero
+ property bool test28: falseProp != zero
+ property bool test29: falseProp == 1
+ property bool test30: falseProp != 1
+ property bool test31: true == zero
+ property bool test32: true != zero
+ property bool test33: true == 1
+ property bool test34: true != 1
+}
+
diff --git a/tests/auto/qml/v4/data/logicalAnd.2.qml b/tests/auto/qml/v4/data/logicalAnd.2.qml
new file mode 100644
index 0000000000..cc3d75bd90
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.2.qml
@@ -0,0 +1,6 @@
+import Qt.v4 1.0
+
+Result {
+ property string s: "foo" && "bar"
+ result: s == "bar"
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.3.qml b/tests/auto/qml/v4/data/logicalAnd.3.qml
new file mode 100644
index 0000000000..6527f05d07
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.3.qml
@@ -0,0 +1,8 @@
+import Qt.v4 1.0
+
+Result {
+ property string s: ""
+ property bool flag: true
+
+ result: (s && flag) == ""
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.4.qml b/tests/auto/qml/v4/data/logicalAnd.4.qml
new file mode 100644
index 0000000000..fbcee91699
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.4.qml
@@ -0,0 +1,8 @@
+import Qt.v4 1.0
+
+Result {
+ property string s: "foo"
+ property bool flag: true
+
+ result: (!flag && s) == false
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.5.qml b/tests/auto/qml/v4/data/logicalAnd.5.qml
new file mode 100644
index 0000000000..f0698463fe
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.5.qml
@@ -0,0 +1,7 @@
+import Qt.v4 1.0
+
+Result {
+ property bool flag: true
+
+ result: (null && flag) == null
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.6.qml b/tests/auto/qml/v4/data/logicalAnd.6.qml
new file mode 100644
index 0000000000..e98b5c99cd
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.6.qml
@@ -0,0 +1,9 @@
+import Qt.v4 1.0
+
+Result {
+ property string s: ""
+ property bool flag: true
+ property string subresult: s && flag
+
+ result: subresult === ""
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.7.qml b/tests/auto/qml/v4/data/logicalAnd.7.qml
new file mode 100644
index 0000000000..0f19d3fb40
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.7.qml
@@ -0,0 +1,9 @@
+import Qt.v4 1.0
+
+Result {
+ property real nan: Number.NaN
+ property bool flag: true
+ property real subresult: nan && flag
+
+ result: isNaN(subresult)
+}
diff --git a/tests/auto/qml/v4/data/logicalAnd.qml b/tests/auto/qml/v4/data/logicalAnd.qml
new file mode 100644
index 0000000000..40fc3616c2
--- /dev/null
+++ b/tests/auto/qml/v4/data/logicalAnd.qml
@@ -0,0 +1,6 @@
+import Qt.v4 1.0
+
+Result {
+ property int a: 10
+ result: a == 10 && a == 2
+}
diff --git a/tests/auto/qml/v4/data/nestedLogicalAnd.qml b/tests/auto/qml/v4/data/nestedLogicalAnd.qml
new file mode 100644
index 0000000000..1358fcea64
--- /dev/null
+++ b/tests/auto/qml/v4/data/nestedLogicalAnd.qml
@@ -0,0 +1,14 @@
+import Qt.v4 1.0
+
+Result {
+ property bool val1: false
+ property bool val2: true
+ property bool val3: false
+
+ property bool b1: (true && true && false)
+ property bool b2: (true && (false && true))
+ property bool b3: ((true && true) && true)
+ property bool b4: (val1 && (val2 && val3)) ? true : false
+
+ result: !b1 && !b2 && b3 && !b4
+}
diff --git a/tests/auto/qml/v4/data/strictEquals.qml b/tests/auto/qml/v4/data/strictEquals.qml
new file mode 100644
index 0000000000..3f4d0d8b3f
--- /dev/null
+++ b/tests/auto/qml/v4/data/strictEquals.qml
@@ -0,0 +1,48 @@
+import QtQuick 2.0
+
+QtObject {
+ property QtObject myprop1: null
+ property QtObject myprop2: QtObject {}
+ property real zero: 0
+ property bool falseProp: false
+
+ property bool test1: myprop1 === false
+ property bool test2: myprop1 === null
+ property bool test3: 5 === myprop1
+ property bool test4: null === myprop1
+ property bool test5: myprop1 !== false
+ property bool test6: myprop1 !== null
+ property bool test7: 5 !== myprop1
+ property bool test8: null !== myprop1
+
+ property bool test9: myprop2 === false
+ property bool test10: myprop2 === null
+ property bool test11: 5 === myprop2
+ property bool test12: null === myprop2
+ property bool test13: myprop2 !== false
+ property bool test14: myprop2 !== null
+ property bool test15: 5 !== myprop2
+ property bool test16: null !== myprop2
+
+ property bool test17: myprop1 === myprop1
+ property bool test18: myprop1 !== myprop1
+ property bool test19: myprop1 === myprop2
+ property bool test20: myprop1 !== myprop2
+ property bool test21: myprop2 === myprop2
+ property bool test22: myprop2 !== myprop2
+
+ property bool test23: myprop1 === "hello"
+ property bool test24: myprop1 !== "hello"
+ property bool test25: myprop2 === "hello"
+ property bool test26: myprop2 !== "hello"
+
+ property bool test27: falseProp === zero
+ property bool test28: falseProp !== zero
+ property bool test29: falseProp === 1
+ property bool test30: falseProp !== 1
+ property bool test31: true === zero
+ property bool test32: true !== zero
+ property bool test33: true === 1
+ property bool test34: true !== 1
+}
+
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
index 91a32268cf..1c89617157 100644
--- a/tests/auto/qml/v4/tst_v4.cpp
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -64,6 +64,8 @@ private slots:
void unnecessaryReeval();
void logicalOr();
void nestedLogicalOr();
+ void logicalAnd();
+ void nestedLogicalAnd();
void conditionalExpr();
void qtscript();
void qtscript_data();
@@ -122,6 +124,8 @@ void tst_v4::qtscript_data()
{
QTest::addColumn<QString>("file");
+ QTest::newRow("equals") << "equals.qml";
+ QTest::newRow("strict equals") << "strictEquals.qml";
QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml";
QTest::newRow("exception on fetch") << "fetchException.qml";
QTest::newRow("logical or") << "logicalOr.qml";
@@ -208,6 +212,115 @@ void tst_v4::nestedLogicalOr()
delete o;
}
+void tst_v4::logicalAnd()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 0);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.2.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.3.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+
+ {
+ // QTBUG-24660
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.4.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.5.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.6.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalAnd.7.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+}
+
+void tst_v4::nestedLogicalAnd()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedLogicalAnd.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+}
+
void tst_v4::conditionalExpr()
{
{