diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qmlformat/data/forOf.formatted.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmlformat/data/forOf.qml | 12 | ||||
-rw-r--r-- | tests/auto/qml/qmlformat/tst_qmlformat.cpp | 7 |
3 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/forOf.formatted.qml b/tests/auto/qml/qmlformat/data/forOf.formatted.qml new file mode 100644 index 0000000000..fa29f16b81 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/forOf.formatted.qml @@ -0,0 +1,9 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + var list = [[1, 2], [3, 4], [5, 6]]; + for (const [x, y] of list) console.log("X: " + x + "; Y: " + y) + for (let [x, y] of list) console.log("X: " + x + "; Y: " + y) + } +} diff --git a/tests/auto/qml/qmlformat/data/forOf.qml b/tests/auto/qml/qmlformat/data/forOf.qml new file mode 100644 index 0000000000..0c3be0d2a2 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/forOf.qml @@ -0,0 +1,12 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + var list = [[1,2],[3,4],[5,6]]; + + for (const [x,y] of list) + console.log("X: "+x+"; Y: "+y); + for (let [x,y] of list) + console.log("X: "+x+"; Y: "+y); + } +} diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index 3b1f232139..03b320c5c8 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -61,6 +61,7 @@ private Q_SLOTS: void testNestedIf(); void testNestedFunctions(); + void testForOf(); #if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled void testExample(); @@ -286,6 +287,12 @@ void TestQmlformat::testNestedFunctions() readTestFile("nestedFunctions.formatted.qml")); } +void TestQmlformat::testForOf() +{ + QCOMPARE(runQmlformat(testFile("forOf.qml"), false, true), + readTestFile("forOf.formatted.qml")); +} + #if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled void TestQmlformat::testExample_data() { |