aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlproperty
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-09-25 20:56:51 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-09-25 20:56:51 +0200
commitf9ef039ad955db67dc3ab6e9056afc4a325aa9a3 (patch)
tree4928ff85fb630639e306ea4eb7137a2064a80c8b /tests/auto/qml/qqmlproperty
parent0238c739f81911f0963cf2c40b27dcfc8e3d38b7 (diff)
parent52fb4685e95e5b44e54d2d0f8ea27dea866c75e9 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/qml/debugger/qqmldebug.cpp Change-Id: I93de5a81b18cdece475870cf7cfba1b9baef2304
Diffstat (limited to 'tests/auto/qml/qqmlproperty')
-rw-r--r--tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml10
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp22
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml b/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml
new file mode 100644
index 0000000000..a0429e0cc8
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+QtObject {
+ property double a: 3.4
+ property string b: a
+
+ property double c: 0.035003945
+ property string d: c
+}
+
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index d6b1c86b88..6ada14ce79 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -147,6 +147,7 @@ private slots:
void registeredCompositeTypeProperty();
void deeplyNestedObject();
void readOnlyDynamicProperties();
+ void floatToStringPrecision();
void copy();
private:
@@ -2054,6 +2055,27 @@ void tst_qqmlproperty::readOnlyDynamicProperties()
delete obj;
}
+void tst_qqmlproperty::floatToStringPrecision()
+{
+ QQmlComponent comp(&engine, testFileUrl("floatToStringPrecision.qml"));
+ QObject *obj = comp.create();
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->property("a").toDouble(), 3.4);
+ QEXPECT_FAIL("", "QVariant's double-to-string conversion is worse than V4's.", Continue);
+ QCOMPARE(obj->property("a").toString(), QLatin1String("3.4"));
+ QCOMPARE(obj->property("b").toDouble(), 3.4);
+ QCOMPARE(obj->property("b").toString(), QLatin1String("3.4"));
+
+ QCOMPARE(obj->property("c").toDouble(), 0.035003945);
+ QEXPECT_FAIL("", "QVariant's double-to-string conversion is worse than V4's.", Continue);
+ QCOMPARE(obj->property("c").toString(), QLatin1String("0.035003945"));
+ QCOMPARE(obj->property("d").toDouble(), 0.035003945);
+ QCOMPARE(obj->property("d").toString(), QLatin1String("0.035003945"));
+
+ delete obj;
+}
+
void tst_qqmlproperty::initTestCase()
{
QQmlDataTest::initTestCase();