aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-10-01 09:41:16 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-10-06 09:02:50 +0200
commit9cfda79202c9c7955a1100861ed2135506302921 (patch)
tree40320d5ec59d15e8d7ff44f69709c26b11514141 /tests
parent2b8ec2eacbf96340ce95a2648450fde07bf3b5c3 (diff)
qmlformat: Fix formatting of for...of loops using array variables
Fixes: QTBUG-86980 Pick-to: 5.15 Change-Id: Id27350821051709894c7645a362cfdf7ce0d279c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlformat/data/forOf.formatted.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/forOf.qml12
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp2
3 files changed, 23 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 c1c248e413..34ce8597e3 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -231,6 +231,8 @@ void TestQmlformat::testFormat_data()
<< "nestedFunctions.formatted.qml" << false << true;
QTest::newRow("multiline comments") << "multilineComment.qml"
<< "multilineComment.formatted.qml" << false << true;
+ QTest::newRow("for of") << "forOf.qml"
+ << "forOf.formatted.qml" << false << true;
}
void TestQmlformat::testFormat()