summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-09-27 14:48:07 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-28 01:04:23 +0200
commit421ee46b982d274fe7e7a2f7a4269e39134d31d2 (patch)
tree9a82acc53c9fc23b9624d2fd4f1a09caaddff5f4 /tests
parent11d1068aa72df599ce2d44e607456b089ec2b84d (diff)
downloadqtscript-421ee46b982d274fe7e7a2f7a4269e39134d31d2.tar.gz
Autotest: Fix unexpected rounding of floating point in date tests
QString("new Date(%0)").arg(1380318500 * 1000.0) expands to "new Date(1.38032e+12)". That's an unnecessary rounding and cuts off interesting bits out of the date. It took me quite a while debugging QScriptEngine trying to find out why the time_t and the JS Date internal numbers were different. Change-Id: Id880f3f11edd0af07e1726eac0242d4a9625c368 Reviewed-by: John Layt <jlayt@kde.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index c75f652..c9318c7 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -5812,7 +5812,7 @@ void tst_QScriptEngine::dateRoundtripJSQtJS()
uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
QScriptEngine eng;
for (int i = 0; i < 8000; ++i) {
- QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0 * 1000.0)").arg(secs));
QDateTime qtDate = jsDate.toDateTime();
QScriptValue jsDate2 = eng.newDate(qtDate);
if (jsDate2.toNumber() != jsDate.toNumber())
@@ -5839,7 +5839,7 @@ void tst_QScriptEngine::dateConversionJSQt()
uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
QScriptEngine eng;
for (int i = 0; i < 8000; ++i) {
- QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0 * 1000.0)").arg(secs));
QDateTime qtDate = jsDate.toDateTime();
QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();