diff options
author | Ulf Hermann <[email protected]> | 2022-02-17 10:02:51 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2022-02-18 12:13:47 +0100 |
commit | 4c716dd19cf88349acc33eddae28c4e9222a3800 (patch) | |
tree | abbbd22d13b75b6e91e5be26110411be66422614 /tests/auto | |
parent | 696f89b1988ed54833406ee8166ffa40e3edaee5 (diff) |
QmlCompiler: Correctly encode inf/nan/-0 into C++
Pick-to: 6.2 6.3
Fixes: QTBUG-100947
Change-Id: If0b05adac91f687daf697f3510e4cf48e7de4537
Reviewed-by: Maximilian Goldstein <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/infinities.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 23 |
3 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index 9a1c9cd0aa..6afc186cad 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -67,6 +67,7 @@ set(qml_files immediateQuit.qml imports/QmlBench/Globals.qml importsFromImportPath.qml + infinities.qml invisibleBase.qml intEnumCompare.qml intOverflow.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/infinities.qml b/tests/auto/qml/qmlcppcodegen/data/infinities.qml new file mode 100644 index 0000000000..5813d7a3ac --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/infinities.qml @@ -0,0 +1,9 @@ +import QtQml + +QtObject { + property real positiveInfinity: Infinity + property real negativeInfinity: -Infinity + property real positiveZero: 0.0 + property real negativeZero: -0.0 + property real naN: NaN +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 99376491fd..b04eb011b3 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -117,6 +117,7 @@ private slots: void revisions(); void invisibleBase(); void notEqualsInt(); + void infinities(); }; void tst_QmlCppCodegen::simpleBinding() @@ -1753,6 +1754,28 @@ void tst_QmlCppCodegen::notEqualsInt() QCOMPARE(t->property("text").toString(), u"Bar"_qs); } +void tst_QmlCppCodegen::infinities() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/infinities.qml"_qs)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + + QCOMPARE(o->property("positiveInfinity").toDouble(), std::numeric_limits<double>::infinity()); + QCOMPARE(o->property("negativeInfinity").toDouble(), -std::numeric_limits<double>::infinity()); + + const double positiveZero = o->property("positiveZero").toDouble(); + QCOMPARE(positiveZero, 0.0); + QVERIFY(!std::signbit(positiveZero)); + + const double negativeZero = o->property("negativeZero").toDouble(); + QCOMPARE(negativeZero, -0.0); + QVERIFY(std::signbit(negativeZero)); + + QVERIFY(qIsNaN(o->property("naN").toDouble())); +} + void tst_QmlCppCodegen::runInterpreted() { if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")) |