aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-07-01 12:15:15 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-07-02 10:51:39 +0200
commite9d03ec78fd95d10e9d9653c1f3d6dc5433de433 (patch)
treea7e1427ce81a937f1def1d8c93f7c0b40ab0c54c /tests
parent05daefeb27e301a29990e8a97a8c8dec70b4a44c (diff)
qmlformat: Fix multiline bindings
Some bindings may turn multiline while formatting. This change makes sure this is handled properly. Fixes: QTBUG-85289 Change-Id: I6df98b926d69a23480003c3d9705bc34c3dd0d5d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 38e0b279d9c36d029918a2d86575050d13778d86)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlformat/data/largeBindings.formatted.qml7
-rw-r--r--tests/auto/qml/qmlformat/data/largeBindings.qml4
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp7
3 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/largeBindings.formatted.qml b/tests/auto/qml/qmlformat/data/largeBindings.formatted.qml
new file mode 100644
index 0000000000..1118c661ed
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/largeBindings.formatted.qml
@@ -0,0 +1,7 @@
+QtObject {
+ smallButNeedsBraces: {
+ if (foo) {
+ bar();
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/largeBindings.qml b/tests/auto/qml/qmlformat/data/largeBindings.qml
new file mode 100644
index 0000000000..7bbc365c13
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/largeBindings.qml
@@ -0,0 +1,4 @@
+QtObject
+{
+ smallButNeedsBraces: if (foo) { bar(); }
+}
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index ba34f0f923..0e0bc53857 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -52,6 +52,7 @@ private Q_SLOTS:
void testReadOnlyProps();
void testVerbatimStrings();
+ void testLargeBindings();
#if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled
void testExample();
@@ -224,6 +225,12 @@ void TestQmlformat::testVerbatimStrings()
readTestFile("verbatimString.formatted.qml"));
}
+void TestQmlformat::testLargeBindings()
+{
+ QCOMPARE(runQmlformat(testFile("largeBindings.qml"), false, true),
+ readTestFile("largeBindings.formatted.qml"));
+}
+
void TestQmlformat::testLineEndings()
{
// macos