--- /dev/null
+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
+ }
+ }
--- /dev/null
+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
+ }
+ }
--- /dev/null
+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
+ }
+ }
--- /dev/null
+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
+ }
+ }
void unaryMinus();
void unaryPlus();
void colorType();
+ void mathAbs();
+ void mathCeil();
+ void mathMax();
+ void mathMin();
private:
QQmlEngine engine;
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"