aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlformat
diff options
context:
space:
mode:
authorJoshua Goins <joshua.goins@kdab.com>2023-09-13 14:21:24 -0400
committerJoshua Goins <joshua.goins@kdab.com>2023-12-08 14:11:27 -0500
commitacf6c9f98880fac3afae08e6710e34f36098abc8 (patch)
tree55dcfb50e53f12fa6a0d7d3f664a39601ac1b1c3 /tests/auto/qml/qmlformat
parent54260530836bdc4d189e7b69d75d2c070318f392 (diff)
qmlformat: Don't remove newlines between import statements
When writing QML files, it's common to use newlines to separate groups of import statements (e.g. separating imports from Qt and your own.) Now qmlformat will preserve the newline grouping, but ensure that it's only one newline and will strip out extra ones. A test is added to ensure this does not regress. Pick-to: 6.5 6.6 Change-Id: I8f158c46886bc0be2313a0e57d6b7c52a1df28fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlformat')
-rw-r--r--tests/auto/qml/qmlformat/data/importStatements.formatted.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/importStatements.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/pragma.formatted.qml1
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp3
4 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/importStatements.formatted.qml b/tests/auto/qml/qmlformat/data/importStatements.formatted.qml
new file mode 100644
index 0000000000..1649b9b9ce
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/importStatements.formatted.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+import QtQuick
+import QtQuick.Controls
+
+import org.test.module
+
+QtObject {
+}
diff --git a/tests/auto/qml/qmlformat/data/importStatements.qml b/tests/auto/qml/qmlformat/data/importStatements.qml
new file mode 100644
index 0000000000..efe1872e93
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/importStatements.qml
@@ -0,0 +1,12 @@
+import QtQml
+
+
+import QtQuick
+import QtQuick.Controls
+
+import org.test.module
+
+
+
+QtObject {
+}
diff --git a/tests/auto/qml/qmlformat/data/pragma.formatted.qml b/tests/auto/qml/qmlformat/data/pragma.formatted.qml
index fba9d15f3c..0bcbfd555c 100644
--- a/tests/auto/qml/qmlformat/data/pragma.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/pragma.formatted.qml
@@ -2,6 +2,7 @@ pragma Singleton
pragma ComponentBehavior: Bound
pragma FunctionSignatureBehavior: Enforced
pragma ValueTypeBehavior: Copy, Addressable
+
import QtQml
QtObject {
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index a29273d14e..fcab28fe28 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -348,6 +348,9 @@ void TestQmlformat::testFormat_data()
QTest::newRow("ellipsisFunctionArgument")
<< "ellipsisFunctionArgument.qml"
<< "ellipsisFunctionArgument.formatted.qml" << QStringList{} << RunOption::OnCopy;
+ QTest::newRow("importStatements")
+ << "importStatements.qml"
+ << "importStatements.formatted.qml" << QStringList{} << RunOption::OnCopy;
}
void TestQmlformat::testFormat()