From 31aa6012bfb575dd85a5083353fd10487dcbcdaa Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 9 Mar 2012 13:09:07 +1000 Subject: [PATCH] Add additional v4 tests. Change-Id: Id33eb50e4a01f3450515f6e666e18cb018f1706e Reviewed-by: Roberto Raggi --- tests/auto/qml/v4/data/mathAbs.qml | 42 ++++++++++++++++ tests/auto/qml/v4/data/mathCeil.qml | 37 ++++++++++++++ tests/auto/qml/v4/data/mathMax.qml | 41 +++++++++++++++ tests/auto/qml/v4/data/mathMin.qml | 41 +++++++++++++++ tests/auto/qml/v4/tst_v4.cpp | 93 +++++++++++++++++++++++++++++++++++ 5 files changed, 254 insertions(+), 0 deletions(-) create mode 100644 tests/auto/qml/v4/data/mathAbs.qml create mode 100644 tests/auto/qml/v4/data/mathCeil.qml create mode 100644 tests/auto/qml/v4/data/mathMax.qml create mode 100644 tests/auto/qml/v4/data/mathMin.qml diff --git a/tests/auto/qml/v4/data/mathAbs.qml b/tests/auto/qml/v4/data/mathAbs.qml new file mode 100644 index 0000000..eb504ae --- /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 0000000..f67838a --- /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 0000000..543b499 --- /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 0000000..7d2a561 --- /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 041d9ab..f8422ac 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" -- 1.7.2.5