aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-08-05 10:37:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-11 11:04:24 +0000
commit7c5570ca8c010b2f8fecd2073dd039e665b83804 (patch)
tree7e858e8097737cf6641f91c0da024045b18cfbfd /tests
parentde7679f38b056211a2bf65fdb916ae35e36ca85d (diff)
qmlformat: Preserve variable declaration scope type
If the user used for(let x;...) we need to preserve the let and must not change it to var. Fixes: QTBUG-105361 Change-Id: I49fc3797505b569cc9b8a9138dd57ec7e70d3eb9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 84dd339e2eb3385eb143f9d5ab282a135635052d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlformat/data/forWithLet.formatted.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/forWithLet.qml8
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp3
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/forWithLet.formatted.qml b/tests/auto/qml/qmlformat/data/forWithLet.formatted.qml
new file mode 100644
index 0000000000..5fecc1d180
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/forWithLet.formatted.qml
@@ -0,0 +1,8 @@
+import QtQml
+
+QtObject {
+ function foo() {
+ for (let i = 0; i < 5; ++i)
+ console.log(i);
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/forWithLet.qml b/tests/auto/qml/qmlformat/data/forWithLet.qml
new file mode 100644
index 0000000000..afed76ebce
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/forWithLet.qml
@@ -0,0 +1,8 @@
+import QtQml
+
+QtObject {
+function foo() {
+for (let i = 0; i < 5; ++i)
+console.log(i);
+}
+}
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index 458a36fc54..9d7beb23a7 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -273,6 +273,9 @@ void TestQmlformat::testFormat_data()
QTest::newRow("settings") << "settings/Example1.qml"
<< "settings/Example1.formatted_mac_cr.qml" << QStringList {}
<< RunOption::OrigToCopy;
+ QTest::newRow("forWithLet")
+ << "forWithLet.qml"
+ << "forWithLet.formatted.qml" << QStringList {} << RunOption::OnCopy;
}
void TestQmlformat::testFormat()