aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-09-12 12:16:47 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-09-21 10:11:05 +0200
commita173d50a9e54d2a21a5207f6c66bb54bb8f3a612 (patch)
tree4b433bf9a693da88dbb7e5d995adbf996dd79b20 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentaf24ed58c250cce32e8d2dc12cfc36de79706f92 (diff)
QmlCompiler: Implement GetIterator and IteratorNext
Each GetIterator generates * A unique iterator variable that keeps track of the current index * In the case of for...of a copy of reference to the list being iterated The result register holds a pointer to the unique iterator so that it can be loaded and stored without resetting it. In order to do anything meaningful with iterators (in the tests) we also need to allow LoadElement with our "optional" types. That is a conversion of undefined and some other type to QVariant or QJSPrimitiveValue. This follows the same pattern as the other "optional"s we already have. For...of is currently not testable because it requires exception handlers. The tests will be added once we get exception handlers. Task-number: QTBUG-116725 Change-Id: I167fe16b983dc34bf86e1840dfcbf2bf682eecc1 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.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 6070503028..5f79aa575d 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -119,6 +119,7 @@ private slots:
void invisibleListElementType();
void invisibleSingleton();
void invisibleTypes();
+ void iteration();
void javaScriptArgument();
void jsArrayMethods();
void jsArrayMethodsWithParams();
@@ -2270,6 +2271,17 @@ void tst_QmlCppCodegen::invisibleTypes()
// QCOMPARE(meta->className(), "DerivedFromInvisible");
}
+void tst_QmlCppCodegen::iteration()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/iteration.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+
+ QCOMPARE(o->objectName(), "a345b345c345"_L1);
+}
+
void tst_QmlCppCodegen::javaScriptArgument()
{
QQmlEngine engine;