diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-02-15 10:27:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-16 08:31:10 +0100 |
commit | 64a5087df7896524bf6af30067f442d1fc8458bc (patch) | |
tree | 5492a8c315062110be7c445c9fe5cfe8812fa7c9 /tests/auto/declarative/v4/tst_v4.cpp | |
parent | 2df9abf7047afbe20b19d156ac37b58d9b047575 (diff) |
Set the type for unary expressions in v4.
Previously unary expressions were being discarded because the type
was not set. Also add tests verifying the results.
Change-Id: Icbb493fbb6f036e59c8a4a1fe232c118312a63a5
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests/auto/declarative/v4/tst_v4.cpp')
-rw-r--r-- | tests/auto/declarative/v4/tst_v4.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 8a550a5c2d..927dc0f082 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -71,6 +71,8 @@ private slots: void qtbug_21883(); void qtbug_22816(); void stringComparison(); + void unaryMinus(); + void unaryPlus(); private: QDeclarativeEngine engine; @@ -304,6 +306,48 @@ void tst_v4::stringComparison() delete o; } +void tst_v4::unaryMinus() +{ + QDeclarativeComponent component(&engine, testFileUrl("unaryMinus.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toReal(), qreal(-18)); + QCOMPARE(o->property("test2").toInt(), -18); + QCOMPARE(o->property("test3").toReal(), qreal(3.7)); + QCOMPARE(o->property("test4").toInt(), 4); + QCOMPARE(o->property("test5").toReal(), qreal(3.3)); + QCOMPARE(o->property("test6").toInt(), 3); + QCOMPARE(o->property("test7").toReal(), qreal(7)); + QCOMPARE(o->property("test8").toInt(), 7); + QCOMPARE(o->property("test9").toReal(), qreal(-4.4)); + QCOMPARE(o->property("test10").toInt(), -4); + + delete o; +} + +void tst_v4::unaryPlus() +{ + QDeclarativeComponent component(&engine, testFileUrl("unaryPlus.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toReal(), qreal(18)); + QCOMPARE(o->property("test2").toInt(), 18); + QCOMPARE(o->property("test3").toReal(), qreal(-3.7)); + QCOMPARE(o->property("test4").toInt(), -4); + QCOMPARE(o->property("test5").toReal(), qreal(-3.3)); + QCOMPARE(o->property("test6").toInt(), -3); + QCOMPARE(o->property("test7").toReal(), qreal(-7)); + QCOMPARE(o->property("test8").toInt(), -7); + QCOMPARE(o->property("test9").toReal(), qreal(4.4)); + QCOMPARE(o->property("test10").toInt(), 4); + + delete o; +} + QTEST_MAIN(tst_v4) #include "tst_v4.moc" |