diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-24 10:30:50 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-12-23 09:02:24 +0100 |
| commit | 35e2bb0906b229658c45a0a5fd4a47494701559e (patch) | |
| tree | 7a491204d4ad6ab3c62fd5aed29a6878389c10f4 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | d6352cd4aa6151be6ef4186cad34ca42bb49ed9f (diff) | |
QmlCompiler: Test that infinities cleanly cast to int
Task-number: QTBUG-108820
Change-Id: I984f6f35ffd32ca9adae31e56010d10c683e5615
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 2e316e571b..e1f36b69db 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -157,6 +157,7 @@ private slots: void lengthAccessArraySequenceCompat(); void storeElementSideEffects(); void numbersInJsPrimitive(); + void infinitiesToInt(); }; void tst_QmlCppCodegen::initTestCase() @@ -3024,6 +3025,25 @@ void tst_QmlCppCodegen::numbersInJsPrimitive() QCOMPARE(asStrings, convertToStrings(stored)); } +void tst_QmlCppCodegen::infinitiesToInt() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/infinitiesToInt.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + const char *props[] = {"a", "b", "c"}; + for (const char *prop : props) { + const QVariant i = o->property(prop); + QCOMPARE(i.metaType(), QMetaType::fromType<int>()); + bool ok = false; + QCOMPARE(i.toInt(&ok), 0); + QVERIFY(ok); + } +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
