diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/negativeyear.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/negativeyear.qml b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml index 11defbe914..e6c857d266 100644 --- a/tests/auto/qml/qqmlecmascript/data/negativeyear.qml +++ b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml @@ -2,7 +2,12 @@ import QtQuick 2.0 import Qt.test 1.0 Item { - function check_negative() { + function check_negative_tostring() { return "result: " + new Date(-2000, 0, 1); } + + function check_negative_toisostring() { + // Make that february, to avoid timezone problems + return "result: " + (new Date(-2000, 1, 1)).toISOString(); + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 07f59eb488..c05ac7a052 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7387,10 +7387,12 @@ void tst_qqmlecmascript::negativeYear() QVERIFY(object != 0); QVariant q; - QMetaObject::invokeMethod(object, "check_negative", - Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object, "check_negative_tostring", Q_RETURN_ARG(QVariant, q)); // Strip the timezone. It should be irrelevant as the date was created with the same one. - QCOMPARE(q.toString().left(32), QStringLiteral("result: Mon Jan 1 00:00:00 -2000")); + QCOMPARE(q.toString().left(32), QStringLiteral("result: Sat Jan 1 00:00:00 -2001")); + + QMetaObject::invokeMethod(object, "check_negative_toisostring", Q_RETURN_ARG(QVariant, q)); + QCOMPARE(q.toString().left(16), QStringLiteral("result: -002000-")); } void tst_qqmlecmascript::concatenatedStringPropertyAccess() |