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>
This commit is contained in:
parent
d6352cd4aa
commit
35e2bb0906
|
@ -106,6 +106,7 @@ set(qml_files
|
|||
imports/QmlBench/Globals.qml
|
||||
importsFromImportPath.qml
|
||||
infinities.qml
|
||||
infinitiesToInt.qml
|
||||
invisibleBase.qml
|
||||
invisibleTypes.qml
|
||||
invisibleListElementType.qml
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
pragma Strict
|
||||
import QtQml
|
||||
|
||||
QtObject {
|
||||
property int a: Infinity
|
||||
property int b: -Infinity
|
||||
property int c: NaN
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue