aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/v4/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/v4/data')
-rw-r--r--tests/auto/qml/v4/data/conditionalExpr.qml4
-rw-r--r--tests/auto/qml/v4/data/integerOperations.qml59
-rw-r--r--tests/auto/qml/v4/data/jsvalueHandling.qml69
-rw-r--r--tests/auto/qml/v4/data/mathCeil.qml4
-rw-r--r--tests/auto/qml/v4/data/mathCos.qml41
-rw-r--r--tests/auto/qml/v4/data/mathFloor.qml37
-rw-r--r--tests/auto/qml/v4/data/mathSin.qml41
-rw-r--r--tests/auto/qml/v4/data/strictEquals.qml5
-rw-r--r--tests/auto/qml/v4/data/stringComparison.qml39
9 files changed, 282 insertions, 17 deletions
diff --git a/tests/auto/qml/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml
index b74a95a94b..704f7c6c5a 100644
--- a/tests/auto/qml/v4/data/conditionalExpr.qml
+++ b/tests/auto/qml/v4/data/conditionalExpr.qml
@@ -2,5 +2,7 @@ import Qt.v4 1.0
Result {
property int n: 2
- result: !n ? 100 : 0
+ property int a: n ? 1 : 0
+ property int b: if (n) { 1 } else { 0 }
+ result: (a && b) ? 0 : 1
}
diff --git a/tests/auto/qml/v4/data/integerOperations.qml b/tests/auto/qml/v4/data/integerOperations.qml
new file mode 100644
index 0000000000..805f4566fb
--- /dev/null
+++ b/tests/auto/qml/v4/data/integerOperations.qml
@@ -0,0 +1,59 @@
+import QtQuick 2.0
+
+Item {
+ property int testa1: i1.p1
+ property int testa2: -testa1 - i1.p1
+
+ property int testb1: i1.p1 & 2
+ property int testb2: i1.p2 & 2
+ property int testb3: 2 & i1.p1
+ property int testb4: 2 & i1.p2
+ property int testb5: i1.p1 & i1.p3
+ property int testb6: i1.p2 & i1.p3
+ property int testb7: i1.p3 & i1.p1
+ property int testb8: i1.p3 & i1.p2
+
+ property int testc1: i1.p1 | 2
+ property int testc2: i1.p2 | 2
+ property int testc3: 2 | i1.p1
+ property int testc4: 2 | i1.p2
+ property int testc5: i1.p1 | i1.p3
+ property int testc6: i1.p2 | i1.p3
+ property int testc7: i1.p3 | i1.p1
+ property int testc8: i1.p3 | i1.p2
+
+ property int testd1: i1.p1 ^ 7
+ property int testd2: 7 ^ i1.p1
+ property int testd3: i1.p1 ^ i1.p4
+ property int testd4: i1.p4 ^ i1.p1
+
+ property int teste1: i1.p4 << 2
+ property int teste2: i1.p5 << 2
+ property int teste3: 2 << i1.p4
+ property int teste4: i1.p4 << i1.p3
+ property int teste5: i1.p5 << i1.p3
+ property int teste6: i1.p3 << i1.p4
+
+ property int testf1: i1.p4 >> 2
+ property int testf2: i1.p5 >> 2
+ property int testf3: 2 >> i1.p4
+ property int testf4: i1.p4 >> i1.p3
+ property int testf5: i1.p5 >> i1.p3
+ property int testf6: i1.p3 >> i1.p4
+
+ property int testg1: i1.p4 >>> 2
+ property int testg2: i1.p5 >>> 2
+ property int testg3: 2 >>> i1.p4
+ property int testg4: i1.p4 >>> i1.p3
+ property int testg5: i1.p5 >>> i1.p3
+ property int testg6: i1.p3 >>> i1.p4
+
+ QtObject {
+ id: i1
+ property int p1: 333
+ property int p2: -666
+ property int p3: 2
+ property int p4: 7
+ property int p5: -7
+ }
+ }
diff --git a/tests/auto/qml/v4/data/jsvalueHandling.qml b/tests/auto/qml/v4/data/jsvalueHandling.qml
new file mode 100644
index 0000000000..d15e878a52
--- /dev/null
+++ b/tests/auto/qml/v4/data/jsvalueHandling.qml
@@ -0,0 +1,69 @@
+import QtQuick 2.0
+import Qt.v4 1.0
+
+JSValueTest {
+ property bool pBool: true
+ property int pInt: 666
+ property real pReal: 3.1415927
+ property string pString: 'foo'
+ property url pUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2'
+ property color pColor: Qt.rgba(1, 0, 0, 0.5)
+ property QtObject pObject: QtObject { property string foo: 'bar' }
+ property var pVar: pUrl
+
+ // Test assignment to QJSValue
+ boolVar: pBool
+ intVar: pInt
+ realVar: pReal
+ stringVar: pString
+ urlVar: pUrl
+ colorVar: pColor
+ objectVar: pObject
+ nullVar: null
+ varVar: pVar
+
+ // Test equivalence
+ property bool boolConversionSuccess: (boolVar == true)
+ property bool intConversionSuccess: (intVar == 666)
+ property bool realConversionSuccess: (realVar == 3.1415927)
+ property bool stringConversionSuccess: (stringVar == 'foo')
+
+ property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2'
+ property bool urlConversionSuccess: (urlVar == comparisonUrl)
+
+ property color comparisonColor: Qt.rgba(1, 0, 0, 0.5)
+ property bool colorConversionSuccess: (colorVar == comparisonColor)
+
+ property bool objectConversionSuccess: (objectVar == pObject)
+ property bool nullConversionSuccess: (nullVar == null)
+
+ property bool varConversionSuccess: (varVar == comparisonUrl)
+
+ // Operations are not handled by V4 - they should pass through correctly
+ property var pVarNot: !boolVar
+ property var pVarComplement: ~intVar
+ property var pVarEqual: (boolVar == pBool)
+ property var pVarLiteralEqual: (boolVar == true)
+ property var pVarUnequal: (urlVar == colorVar)
+ property var pVarComparison: (intVar <= intVar)
+ property var pVarShift: (intVar >> 1)
+
+ Component.onCompleted: {
+ if (!boolConversionSuccess) console.warn('QV4: bool conversion failed');
+ if (!intConversionSuccess) console.warn('QV4: int conversion failed');
+ if (!realConversionSuccess) console.warn('QV4: real conversion failed');
+ if (!stringConversionSuccess) console.warn('QV4: string conversion failed');
+ if (!urlConversionSuccess) console.warn('QV4: url conversion failed');
+ if (!colorConversionSuccess) console.warn('QV4: color conversion failed');
+ if (!objectConversionSuccess) console.warn('QV4: object conversion failed');
+ if (!nullConversionSuccess) console.warn('QV4: null conversion failed');
+ if (!varConversionSuccess) console.warn('QV4: var conversion failed');
+ if (pVarNot != false) console.warn('QV4: var negation impeded');
+ if (pVarComplement != ~666) console.warn('QV4: var complement impeded');
+ if (pVarEqual != true) console.warn('QV4: var equality impeded');
+ if (pVarLiteralEqual != true) console.warn('QV4: var/literal equality impeded');
+ if (pVarUnequal != false) console.warn('QV4: var unequality impeded');
+ if (pVarComparison != true) console.warn('QV4: var comparison impeded');
+ if (pVarShift != 333) console.warn('QV4: var shift impeded');
+ }
+}
diff --git a/tests/auto/qml/v4/data/mathCeil.qml b/tests/auto/qml/v4/data/mathCeil.qml
index f67838a445..1f65066233 100644
--- a/tests/auto/qml/v4/data/mathCeil.qml
+++ b/tests/auto/qml/v4/data/mathCeil.qml
@@ -22,6 +22,9 @@ Item {
property real subtest10: Math.ceil(i1.p10)
property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity
+ property real subtest11: Math.ceil(i1.p11)
+ property bool test11: subtest11 === 0 && (1/subtest11) === -Infinity
+
QtObject {
id: i1
property real p1: -3.7
@@ -33,5 +36,6 @@ Item {
property real p8: Number.POSITIVE_INFINITY
property real p9: 0
property real p10: -0
+ property real p11: -0.5
}
}
diff --git a/tests/auto/qml/v4/data/mathCos.qml b/tests/auto/qml/v4/data/mathCos.qml
new file mode 100644
index 0000000000..44c47e9f15
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathCos.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.cos(i1.p1)
+ property real test2: Math.cos(i1.p2)
+
+ property real subtest3: Math.cos()
+ property real subtest4: Math.cos(i1.p4)
+ property bool test3: isNaN(subtest3)
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.cos(i1.p5)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.cos(i1.p6)
+
+ property real subtest7: Math.cos(i1.p7)
+ property real subtest8: Math.cos(i1.p8)
+ property bool test7: isNaN(subtest7)
+ property bool test8: isNaN(subtest8)
+
+ property real subtest9: Math.cos(i1.p9)
+ property bool test9: subtest9 === 1
+ property real subtest10: Math.cos(i1.p10)
+ property bool test10: subtest10 === 1
+
+ property real subtest11: Math.PI / 6.66
+ property real test11: Math.cos(subtest11)
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.4
+ property real p4: Number.NaN
+ property string p5: "hello world"
+ property string p6: "82.6"
+ property real p7: Number.NEGATIVE_INFINITY
+ property real p8: Number.POSITIVE_INFINITY
+ property real p9: 0
+ property real p10: -0
+ }
+ }
diff --git a/tests/auto/qml/v4/data/mathFloor.qml b/tests/auto/qml/v4/data/mathFloor.qml
new file mode 100644
index 0000000000..3473dccd10
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathFloor.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.floor(i1.p1)
+ property real test2: Math.floor(i1.p2)
+
+ property real subtest3: Math.floor()
+ property real subtest4: Math.floor(i1.p4)
+ property bool test3: isNaN(subtest3)
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.floor(i1.p5)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.floor(i1.p6)
+
+ property real subtest7: Math.floor(i1.p7)
+ property real subtest8: Math.floor(i1.p8)
+ property bool test7: subtest7 === Number.NEGATIVE_INFINITY
+ property bool test8: subtest8 === Number.POSITIVE_INFINITY
+
+ property real test9: Math.floor(i1.p9)
+ property real subtest10: Math.floor(i1.p10)
+ property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.4
+ property real p4: Number.NaN
+ property string p5: "hello world"
+ property string p6: "82.6"
+ property real p7: Number.NEGATIVE_INFINITY
+ property real p8: Number.POSITIVE_INFINITY
+ property real p9: 0
+ property real p10: -0
+ }
+ }
diff --git a/tests/auto/qml/v4/data/mathSin.qml b/tests/auto/qml/v4/data/mathSin.qml
new file mode 100644
index 0000000000..c48ec03fee
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathSin.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.sin(i1.p1)
+ property real test2: Math.sin(i1.p2)
+
+ property real subtest3: Math.sin()
+ property real subtest4: Math.sin(i1.p4)
+ property bool test3: isNaN(subtest3)
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.sin(i1.p5)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.sin(i1.p6)
+
+ property real subtest7: Math.sin(i1.p7)
+ property real subtest8: Math.sin(i1.p8)
+ property bool test7: isNaN(subtest7)
+ property bool test8: isNaN(subtest8)
+
+ property real subtest9: Math.sin(i1.p9)
+ property bool test9: subtest9 === 0 && (1/subtest9) === Infinity
+ property real subtest10: Math.sin(i1.p10)
+ property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity
+
+ property real subtest11: Math.PI / 6.66
+ property real test11: Math.sin(subtest11)
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.4
+ property real p4: Number.NaN
+ property string p5: "hello world"
+ property string p6: "82.6"
+ property real p7: Number.NEGATIVE_INFINITY
+ property real p8: Number.POSITIVE_INFINITY
+ property real p9: 0
+ property real p10: -0
+ }
+ }
diff --git a/tests/auto/qml/v4/data/strictEquals.qml b/tests/auto/qml/v4/data/strictEquals.qml
index 3f4d0d8b3f..503ca50454 100644
--- a/tests/auto/qml/v4/data/strictEquals.qml
+++ b/tests/auto/qml/v4/data/strictEquals.qml
@@ -44,5 +44,10 @@ QtObject {
property bool test32: true !== zero
property bool test33: true === 1
property bool test34: true !== 1
+
+ property bool test35: zero === 5.0
+ property bool test36: zero !== 5.0
+ property bool test37: zero === 1
+ property bool test38: zero !== 1
}
diff --git a/tests/auto/qml/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml
index 64b6798c69..d9eab5389e 100644
--- a/tests/auto/qml/v4/data/stringComparison.qml
+++ b/tests/auto/qml/v4/data/stringComparison.qml
@@ -5,6 +5,7 @@ QtObject {
property string string2: "aa"
property string string3: "aaab"
property string string4: "c"
+ property string string5: string2 + string4
property bool test1: string1 > string2
property bool test2: string2 < string1
@@ -12,23 +13,29 @@ QtObject {
property bool test4: string3 < string1
property bool test5: string1 < string4
property bool test6: string4 > string1
+ property bool test7: string1 < string5
+ property bool test8: string5 > string1
- property bool test7: string1 == "aaba"
- property bool test8: string1 != "baa"
- property bool test9: string1 === "aaba"
- property bool test10: string1 !== "baa"
- property bool test11: string4 == "c"
- property bool test12: string4 != "d"
- property bool test13: string4 === "c"
- property bool test14: string4 !== "d"
+ property bool test9: string1 == "aaba"
+ property bool test10: string1 != "baa"
+ property bool test11: string1 === "aaba"
+ property bool test12: string1 !== "baa"
+ property bool test13: string4 == "c"
+ property bool test14: string4 != "d"
+ property bool test15: string4 === "c"
+ property bool test16: string4 !== "d"
+ property bool test17: string5 === "aac"
+ property bool test18: string5 !== "aad"
- property bool test15: string1 >= string2
- property bool test16: string2 <= string1
- property bool test17: string1 >= string3
- property bool test18: string3 <= string1
- property bool test19: string1 <= string4
- property bool test20: string4 >= string1
- property bool test21: string4 <= "c"
- property bool test22: string4 >= "c"
+ property bool test19: string1 >= string2
+ property bool test20: string2 <= string1
+ property bool test21: string1 >= string3
+ property bool test22: string3 <= string1
+ property bool test23: string1 <= string4
+ property bool test24: string4 >= string1
+ property bool test25: string4 <= "c"
+ property bool test26: string4 >= "c"
+ property bool test27: string5 <= "aac"
+ property bool test28: string5 >= "aac"
}