aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-02-24 08:57:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-03-14 20:53:52 +0100
commit6eff3465b5192e40343f0486ef7076da2ed28bed (patch)
tree5b1b4f65b2396ebd7152ab8f13300e5f5dd33421 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent9de2b11a7033a1969156277bafa848b5c178baa1 (diff)
QmlCompiler: Implement generate_DefineArray
Using the type cloning and adaption mechanism we can now determine what kind of list we have to create in order to avoid a later conversion. We can even propagate the type adjustment into the element types we read. Fixes: QTBUG-100157 Change-Id: Ia2f160ebae56f39ee5946f49d2f8c5b4986a6b77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> 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.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 74794eb7fc..e8861b3b84 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -126,6 +126,7 @@ private slots:
void functionTakingVar();
void testIsnan();
void fallbackLookups();
+ void typedArray();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -1904,6 +1905,34 @@ void tst_QmlCppCodegen::fallbackLookups()
QCOMPARE(singleton->objectName(), QStringLiteral("dd96"));
}
+void tst_QmlCppCodegen::typedArray()
+{
+ QQmlEngine engine;
+ const QUrl document(u"qrc:/TestTypes/typedArray.qml"_qs);
+ QQmlComponent c(&engine, document);
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+ QDateTime date;
+ QVERIFY(qvariant_cast<QList<int>>(o->property("values2")).isEmpty());
+ QCOMPARE(qvariant_cast<QList<int>>(o->property("values3")),
+ QList<int>({1, 2, 3, 4}));
+ QCOMPARE(qvariant_cast<QList<QDateTime>>(o->property("values4")),
+ QList<QDateTime>({date, date, date}));
+ QCOMPARE(qvariant_cast<QList<double>>(o->property("values5")),
+ QList<double>({1, 2, 3.4, 30, 0, 0}));
+ date = QDateTime::currentDateTime();
+ o->setProperty("aDate", date);
+ QCOMPARE(qvariant_cast<QList<QDateTime>>(o->property("values4")),
+ QList<QDateTime>({date, date, date}));
+
+ QQmlListProperty<QObject> values6
+ = qvariant_cast<QQmlListProperty<QObject>>(o->property("values6"));
+ QCOMPARE(values6.count(&values6), 3);
+ for (int i = 0; i < 3; ++i)
+ QCOMPARE(values6.at(&values6, i), o.data());
+}
+
void tst_QmlCppCodegen::runInterpreted()
{
if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER"))