diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-10-24 15:06:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2014-10-24 17:03:51 +0200 |
commit | f06daaf3d8747c6c0a277bf055c80d8f2e7bcc81 (patch) | |
tree | 8e5e77c72e33dbe0771b48aabd12325722ec2422 /tests/auto/qml | |
parent | f876562de8eb978cea39fe72e76c49ae51ff2f97 (diff) |
Properly handle negative years when printing JS Dates to strings.
JavaScript knows a year 0. That is correctly translated into QDateTime
terms when creating a Date object, but it's not correctly translated
back when converting the JavaScript date to a string.
Task-number: QTBUG-29491
Change-Id: I46b200a144434187656d08e87f422f97523acd0e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/negativeyear.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/negativeyear.qml b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml new file mode 100644 index 0000000000..11defbe914 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + function check_negative() { + return "result: " + new Date(-2000, 0, 1); + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 196f6b96f9..019d6790e1 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -200,6 +200,7 @@ private slots: void sequenceSort(); void dateParse(); void utcDate(); + void negativeYear(); void qtbug_22464(); void qtbug_21580(); void singleV8BindingDestroyedDuringEvaluation(); @@ -7378,6 +7379,22 @@ void tst_qqmlecmascript::utcDate() QVERIFY(q.toBool() == true); } +void tst_qqmlecmascript::negativeYear() +{ + QQmlComponent component(&engine, testFileUrl("negativeyear.qml")); + + QObject *object = component.create(); + if (object == 0) + qDebug() << component.errorString(); + QVERIFY(object != 0); + + QVariant q; + QMetaObject::invokeMethod(object, "check_negative", + 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")); +} + void tst_qqmlecmascript::concatenatedStringPropertyAccess() { QQmlComponent component(&engine, testFileUrl("concatenatedStringPropertyAccess.qml")); |