aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-03-09 13:09:07 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-12 23:28:31 +0100
commit31aa6012bfb575dd85a5083353fd10487dcbcdaa (patch)
tree2dd3cf309fa3908b5a74c6686fc55cede031e7b3 /tests
parent5f1ebe4df09a4899aa32a1c19c368e5260b5b246 (diff)
Add additional v4 tests.
Change-Id: Id33eb50e4a01f3450515f6e666e18cb018f1706e Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/v4/data/mathAbs.qml42
-rw-r--r--tests/auto/qml/v4/data/mathCeil.qml37
-rw-r--r--tests/auto/qml/v4/data/mathMax.qml41
-rw-r--r--tests/auto/qml/v4/data/mathMin.qml41
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp93
5 files changed, 254 insertions, 0 deletions
diff --git a/tests/auto/qml/v4/data/mathAbs.qml b/tests/auto/qml/v4/data/mathAbs.qml
new file mode 100644
index 0000000000..eb504ae4d8
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathAbs.qml
@@ -0,0 +1,42 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.abs(i1.p1)
+ property real test2: Math.abs(i1.p2)
+
+ property int test3: Math.abs(i1.p3)
+ property int test4: Math.abs(i1.p4)
+
+ property real subtest5: Math.abs()
+ property real subtest6: Math.abs(i1.p6)
+ property bool test5: isNaN(subtest5)
+ property bool test6: isNaN(subtest6)
+
+ property real subtest7: Math.abs(i1.p7)
+ property bool test7: isNaN(subtest7)
+ property int test8: Math.abs(i1.p8)
+
+ property real subtest9: Math.abs(i1.p9)
+ property real subtest10: Math.abs(i1.p10)
+ property bool test9: subtest9 === Number.POSITIVE_INFINITY
+ property bool test10: subtest10 === Number.POSITIVE_INFINITY
+
+ property int test11: Math.abs(i1.p11)
+ property real subtest12: Math.abs(i1.p12)
+ property bool test12: subtest12 === 0 && (1/subtest12) === Infinity
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.5
+ property int p3: 18
+ property int p4: -72
+ property real p6: Number.NaN
+ property string p7: "hello world"
+ property string p8: "82"
+ property real p9: Number.NEGATIVE_INFINITY
+ property real p10: Number.POSITIVE_INFINITY
+ property real p11: 0
+ property real p12: -0
+ }
+ }
diff --git a/tests/auto/qml/v4/data/mathCeil.qml b/tests/auto/qml/v4/data/mathCeil.qml
new file mode 100644
index 0000000000..f67838a445
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathCeil.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.ceil(i1.p1)
+ property real test2: Math.ceil(i1.p2)
+
+ property real subtest3: Math.ceil()
+ property real subtest4: Math.ceil(i1.p4)
+ property bool test3: isNaN(subtest3)
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.ceil(i1.p5)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.ceil(i1.p6)
+
+ property real subtest7: Math.ceil(i1.p7)
+ property real subtest8: Math.ceil(i1.p8)
+ property bool test7: subtest7 === Number.NEGATIVE_INFINITY
+ property bool test8: subtest8 === Number.POSITIVE_INFINITY
+
+ property real test9: Math.ceil(i1.p9)
+ property real subtest10: Math.ceil(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/mathMax.qml b/tests/auto/qml/v4/data/mathMax.qml
new file mode 100644
index 0000000000..543b4994aa
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathMax.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.max(i1.p1, i1.p2)
+ property real test2: Math.max(i1.p2, i1.p3)
+
+ property real subtest3: Math.max()
+ property real subtest4: Math.max(i1.p4)
+ property bool test3: subtest3 === -Infinity
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.max(i1.p5, i1.p1)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.max(i1.p6, i1.p3)
+
+ property real test7: Math.max(i1.p7, i1.p2)
+ property real subtest8: Math.max(i1.p8, i1.p2)
+ property bool test8: subtest8 === Number.POSITIVE_INFINITY
+
+ property real subtest9: Math.max(i1.p10, i1.p9)
+ property bool test9: subtest9 === 0 && (1/subtest9) === Infinity
+
+ property real test10: Math.max(i1.p11, i1.p1)
+ property real test11: Math.max(i1.p11, i1.p2)
+ property real test12: Math.max(i1.p1, i1.p2, i1.p3)
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.4
+ property int p3: 7
+ 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
+ property var p11: null
+ }
+ }
diff --git a/tests/auto/qml/v4/data/mathMin.qml b/tests/auto/qml/v4/data/mathMin.qml
new file mode 100644
index 0000000000..7d2a561623
--- /dev/null
+++ b/tests/auto/qml/v4/data/mathMin.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+
+Item {
+ property real test1: Math.min(i1.p1, i1.p2)
+ property real test2: Math.min(i1.p2, i1.p3)
+
+ property real subtest3: Math.min()
+ property real subtest4: Math.min(i1.p4)
+ property bool test3: subtest3 === Infinity
+ property bool test4: isNaN(subtest4)
+
+ property real subtest5: Math.min(i1.p5, i1.p1)
+ property bool test5: isNaN(subtest5)
+ property real test6: Math.min(i1.p6, i1.p3)
+
+ property real subtest7: Math.min(i1.p7, i1.p2)
+ property bool test7: subtest7 === Number.NEGATIVE_INFINITY
+ property real test8: Math.min(i1.p8, i1.p2)
+
+ property real subtest9: Math.min(i1.p10, i1.p9)
+ property bool test9: subtest9 === 0 && (1/subtest9) === -Infinity
+
+ property real test10: Math.min(i1.p11, i1.p1)
+ property real test11: Math.min(i1.p11, i1.p2)
+ property real test12: Math.min(i1.p1, i1.p2, i1.p3)
+
+ QtObject {
+ id: i1
+ property real p1: -3.7
+ property real p2: 4.4
+ property int p3: 95
+ 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
+ property var p11: null
+ }
+ }
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
index 041d9ab8e6..f8422ac73c 100644
--- a/tests/auto/qml/v4/tst_v4.cpp
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -75,6 +75,10 @@ private slots:
void unaryMinus();
void unaryPlus();
void colorType();
+ void mathAbs();
+ void mathCeil();
+ void mathMax();
+ void mathMin();
private:
QQmlEngine engine;
@@ -383,6 +387,95 @@ void tst_v4::colorType()
delete o;
}
+void tst_v4::mathAbs()
+{
+ QQmlComponent component(&engine, testFileUrl("mathAbs.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(3.7));
+ QCOMPARE(o->property("test2").toReal(), qreal(4.5));
+ QCOMPARE(o->property("test3").toInt(), 18);
+ QCOMPARE(o->property("test4").toInt(), 72);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toInt(), 82);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+ QCOMPARE(o->property("test11").toInt(), 0);
+ //QCOMPARE(o->property("test12").toBool(), true); //QTBUG-24706
+
+ delete o;
+}
+
+void tst_v4::mathCeil()
+{
+ QQmlComponent component(&engine, testFileUrl("mathCeil.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(-3));
+ QCOMPARE(o->property("test2").toReal(), qreal(5));
+ QCOMPARE(o->property("test3").toBool(), true);
+ //QCOMPARE(o->property("test4").toBool(), true); //QTBUG-24706
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toReal(), qreal(83));
+ //QCOMPARE(o->property("test7").toBool(), true); //QTBUG-24706
+ //QCOMPARE(o->property("test8").toBool(), true); //QTBUG-24706
+ QCOMPARE(o->property("test9").toInt(), 0);
+ //QCOMPARE(o->property("test10").toBool(), true); //QTBUG-24706
+
+ delete o;
+}
+
+void tst_v4::mathMax()
+{
+ QQmlComponent component(&engine, testFileUrl("mathMax.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test2").toReal(), qreal(7));
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toReal(), qreal(82.6));
+ QCOMPARE(o->property("test7").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test8").toBool(), true);
+ //QCOMPARE(o->property("test9").toBool(), true); //QTBUG-24706
+ QCOMPARE(o->property("test10").toReal(), qreal(0));
+ QCOMPARE(o->property("test11").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test12").toReal(), qreal(7));
+
+ delete o;
+}
+
+void tst_v4::mathMin()
+{
+ QQmlComponent component(&engine, testFileUrl("mathMin.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(-3.7));
+ QCOMPARE(o->property("test2").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toReal(), qreal(82.6));
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toReal(), qreal(4.4));
+ //QCOMPARE(o->property("test9").toBool(), true); //QTBUG-24706
+ QCOMPARE(o->property("test10").toReal(), qreal(-3.7));
+ QCOMPARE(o->property("test11").toReal(), qreal(0));
+ QCOMPARE(o->property("test12").toReal(), qreal(-3.7));
+ delete o;
+}
+
QTEST_MAIN(tst_v4)
#include "tst_v4.moc"