aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-02-22 17:13:36 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-02-25 12:49:13 +0000
commitb959074afb43d25c1a8818e0528004f8cf073ae2 (patch)
tree9c00bb615057b51ded5f26795c8b7e02cf706dc0 /tests
parentcdb8eb988e572411030486ad2834ae54e4567bf3 (diff)
Unify and fix number to string conversion with radix
Previously, the loop that generated the string could fail to terminate with certain numbers as input. Also, the algorithm was duplicated in two places. Change-Id: Ie2075148d931e7cfcedb5bcd23af61e2e8afc232 Fixes: QTBUG-73999 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index aaaaf09925..f849403cd8 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -362,6 +362,7 @@ private slots:
void hugeObject();
void templateStringTerminator();
void arrayAndException();
+ void numberToStringWithRadix();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8878,6 +8879,21 @@ void tst_qqmlecmascript::arrayAndException()
QVERIFY(value.isError());
}
+void tst_qqmlecmascript::numberToStringWithRadix()
+{
+ QJSEngine engine;
+ {
+ const QJSValue value = engine.evaluate(".5.toString(5)");
+ QVERIFY(!value.isError());
+ QVERIFY(value.toString().startsWith("0.2222222222"));
+ }
+ {
+ const QJSValue value = engine.evaluate(".05.toString(5)");
+ QVERIFY(!value.isError());
+ QVERIFY(value.toString().startsWith("0.01111111111"));
+ }
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"