diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-07-28 16:41:09 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-22 17:16:53 +0200 |
| commit | d908d5e57c454a788b49e161c507fdd7782cab12 (patch) | |
| tree | 9c4154e9383efc9596790f33232d43971cecaa8d /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 9e3b681460b3d61ff5bc9e35e437a849ff94e221 (diff) | |
QmlCompiler: Allow construction of Array objects
Currently, only the constructor form of the Array function is compiled.
We only compile construction of Array objects if we can determine that
they are immediately assigned to a typed list. Consequently, we don't
have to deal with sparse arrays.
Change-Id: I2abd15139eb9a0d530ad49df7313b8dba415ae77
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.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 29a9e9c637..b056da847c 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -39,6 +39,7 @@ private slots: void anchorsFill(); void argumentConversion(); void array(); + void arrayCtor(); void asCast(); void attachedBaseEnum(); void attachedSelf(); @@ -613,6 +614,22 @@ void tst_QmlCppCodegen::array() QCOMPARE(value2.property(u"length"_s).toInt(), 0); } +void tst_QmlCppCodegen::arrayCtor() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/arrayCtor.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QCOMPARE(object->property("defaultCtor"), QVariant::fromValue(QList<int>())); + QCOMPARE(object->property("oneArgCtor"), QVariant::fromValue(QList<int>(5))); + QCOMPARE(object->property("multiArgCtor"), QVariant::fromValue(QList<int>({2, 3, 3, 4}))); + QCOMPARE(object->property("arrayTrue"), QVariant::fromValue(QList<bool>({true}))); + QCOMPARE(object->property("arrayFalse"), QVariant::fromValue(QList<bool>({false}))); + QCOMPARE(object->property("arrayNegative"), QVariant::fromValue(QList<double>())); +} + void tst_QmlCppCodegen::asCast() { QQmlEngine engine; |
