aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-06-29 14:01:22 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-07-05 19:50:24 +0200
commit7d36ec0bd9cd4747dbf33e92b8188fe25c295b88 (patch)
tree10d69c518b60035c618c425f35b0b9f58bc6200a /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent46396070368568d44597a36b7c7646f139d92b23 (diff)
QmlCompiler: Don't push type conversions back into the engine
In many cases we can generate better code for type conversions. Furthermore, the engine only does QMetaType::convert(). This misses a lot of conversions we do in other places. Pick-to: 6.4 Change-Id: I1526ec327d189420885f6a7385f6cc1c2c94b19e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 47822eb663..7ea6f622ad 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -128,6 +128,7 @@ private slots:
void conversionDecrement();
void unstoredUndefined();
void registerPropagation();
+ void argumentConversion();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -2347,6 +2348,28 @@ void tst_QmlCppCodegen::registerPropagation()
QCOMPARE(result, 1);
}
+void tst_QmlCppCodegen::argumentConversion()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/argumentConversion.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+
+ auto checkNaN = [&](const char *propName) {
+ const QVariant prop = o->property(propName);
+ QCOMPARE(prop.metaType(), QMetaType::fromType<double>());
+ QVERIFY(qIsNaN(prop.toDouble()));
+ };
+
+ checkNaN("a");
+ checkNaN("b");
+ checkNaN("e");
+
+ QCOMPARE(o->property("c").toDouble(), 3.0);
+ QCOMPARE(o->property("d").toDouble(), -1.0);
+ QCOMPARE(o->property("f").toDouble(), 10.0);
+}
+
void tst_QmlCppCodegen::runInterpreted()
{
#ifdef Q_OS_ANDROID