aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlformat/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmlformat/data')
-rw-r--r--tests/auto/qml/qmlformat/data/Annotations.formatted.qml17
-rw-r--r--tests/auto/qml/qmlformat/data/Example1.formatted.2spaces.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/Example1.formatted.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/Example1.formatted.tabs.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/Example1.formatted2.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/FrontInline.formatted.qml3
-rw-r--r--tests/auto/qml/qmlformat/data/arrayEndComma.formatted.qml4
-rw-r--r--tests/auto/qml/qmlformat/data/arrayEndComma.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/blanklinesAfterComment.formatted.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/blanklinesAfterComment.qml15
-rw-r--r--tests/auto/qml/qmlformat/data/class.formatted.js5
-rw-r--r--tests/auto/qml/qmlformat/data/class.js1
-rw-r--r--tests/auto/qml/qmlformat/data/commentInEnum.formatted.qml11
-rw-r--r--tests/auto/qml/qmlformat/data/commentInEnum.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/commentInQmlObject.formatted.qml4
-rw-r--r--tests/auto/qml/qmlformat/data/commentInQmlObject.qml5
-rw-r--r--tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml24
-rw-r--r--tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/directives.formatted.js8
-rw-r--r--tests/auto/qml/qmlformat/data/directives.js9
-rw-r--r--tests/auto/qml/qmlformat/data/directivesWithComments.formatted.js6
-rw-r--r--tests/auto/qml/qmlformat/data/directivesWithComments.js8
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/ecmaScriptClassInQml.formatted.qml2
-rw-r--r--tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.formatted.qml13
-rw-r--r--tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.qml11
-rw-r--r--tests/auto/qml/qmlformat/data/enumWithValues.formatted.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/enumWithValues.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/escapeChars.formatted.qml16
-rw-r--r--tests/auto/qml/qmlformat/data/escapeChars.qml16
-rw-r--r--tests/auto/qml/qmlformat/data/esm.formatted.mjs44
-rw-r--r--tests/auto/qml/qmlformat/data/esm.mjs33
-rw-r--r--tests/auto/qml/qmlformat/data/filesOption/valid1.formatted.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/filesOption/valid1.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/filesOption/valid2.formatted.qml10
-rw-r--r--tests/auto/qml/qmlformat/data/filesOption/valid2.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/forOf.formatted.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/functionsSpacing.formatted.qml3
-rw-r--r--tests/auto/qml/qmlformat/data/importStatements.formatted.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/importStatements.qml12
-rw-r--r--tests/auto/qml/qmlformat/data/javascriptBlock.formatted.qml6
-rw-r--r--tests/auto/qml/qmlformat/data/javascriptBlock.qml5
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.formatted.js6
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.js1
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaWithIfElse.formatted.js7
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaWithIfElse.js1
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.formatted.js9
-rw-r--r--tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.js1
-rw-r--r--tests/auto/qml/qmlformat/data/messyIfStatement.formatted.js4
-rw-r--r--tests/auto/qml/qmlformat/data/messyIfStatement.js2
-rw-r--r--tests/auto/qml/qmlformat/data/mini_esm.formattedTabs.mjs20
-rw-r--r--tests/auto/qml/qmlformat/data/mini_esm.mjs3
-rw-r--r--tests/auto/qml/qmlformat/data/multilineComment.formatted.qml6
-rw-r--r--tests/auto/qml/qmlformat/data/nestedFunctions.formatted.qml2
-rw-r--r--tests/auto/qml/qmlformat/data/nestedIf.formatted.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/objectDestructuring.formatted.qml137
-rw-r--r--tests/auto/qml/qmlformat/data/objectDestructuring.qml77
-rw-r--r--tests/auto/qml/qmlformat/data/objectsSpacing.formatted.qml3
-rw-r--r--tests/auto/qml/qmlformat/data/objectsSpacing.qml4
-rw-r--r--tests/auto/qml/qmlformat/data/pragma.formatted.js4
-rw-r--r--tests/auto/qml/qmlformat/data/pragma.formatted.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/pragma.js1
-rw-r--r--tests/auto/qml/qmlformat/data/pragma.qml8
-rw-r--r--tests/auto/qml/qmlformat/data/propertyNames.formatted.qml6
-rw-r--r--tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml2
-rw-r--r--tests/auto/qml/qmlformat/data/simpleJSStatement.formatted.js1
-rw-r--r--tests/auto/qml/qmlformat/data/simpleJSStatement.js1
-rw-r--r--tests/auto/qml/qmlformat/data/simpleLoop.formatted.js4
-rw-r--r--tests/auto/qml/qmlformat/data/simpleLoop.js1
-rw-r--r--tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.formatted.js4
-rw-r--r--tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.js1
-rw-r--r--tests/auto/qml/qmlformat/data/statesAndTransitions.formatted.qml9
-rw-r--r--tests/auto/qml/qmlformat/data/threeFunctions.formattedFuncSpacing.js11
-rw-r--r--tests/auto/qml/qmlformat/data/threeFunctions.formattedTabs.js9
-rw-r--r--tests/auto/qml/qmlformat/data/threeFunctions.formattedW2.js9
-rw-r--r--tests/auto/qml/qmlformat/data/threeFunctionsOneLine.js1
-rw-r--r--tests/auto/qml/qmlformat/data/twoFunctions.formatted.js12
-rw-r--r--tests/auto/qml/qmlformat/data/twoFunctions.js3
81 files changed, 793 insertions, 57 deletions
diff --git a/tests/auto/qml/qmlformat/data/Annotations.formatted.qml b/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
index 92cbeb55f7..019b7f0141 100644
--- a/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
@@ -10,17 +10,14 @@ import QtCharts 2.0
@Pippo {
atg1: 3
}
-@Annotation2 {
-}
+@Annotation2 {}
Item {
- @Annotate {
- }
+ @Annotate {}
anchors.fill: parent
@AnnotateMore {
property int x: 5
}
- @AnnotateALot {
- }
+ @AnnotateALot {}
property variant othersSlice: 0
//![1]
@@ -79,19 +76,17 @@ Item {
@BindingAnn {
bType: 2
}
- val2: Item {
- }
+ val2: Item {}
@BindingAnn {
bType: 3
}
val3: [
- Item {
- }
+ Item {}
]
@BindingAnn {
bType: 4
}
- Animation on val {
+ Animation on val {
duration: 34
}
}
diff --git a/tests/auto/qml/qmlformat/data/Example1.formatted.2spaces.qml b/tests/auto/qml/qmlformat/data/Example1.formatted.2spaces.qml
index 8b181f607e..b1662e8898 100644
--- a/tests/auto/qml/qmlformat/data/Example1.formatted.2spaces.qml
+++ b/tests/auto/qml/qmlformat/data/Example1.formatted.2spaces.qml
@@ -43,7 +43,7 @@ Item {
property bool some_bool: false
// This comment is related to the property animation
- PropertyAnimation on x {
+ PropertyAnimation on x {
id: foo2
x: 3
y: x + 3
@@ -54,6 +54,7 @@ Item {
// Another orphan
// More orphans
+
property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3]
property bool something_computed: function (x) {
const PI = 3, DAYS_PER_YEAR = 365.25;
@@ -124,6 +125,7 @@ Item {
}
// Another orphan inside something_computed
+
return "foobar";
}()
@@ -133,11 +135,9 @@ Item {
// This is an orphan
// This is a cool text
- Text {
- },
+ Text {},
// This is a cool rectangle
- Rectangle {
- }
+ Rectangle {}
]
// some_read_only_bool
diff --git a/tests/auto/qml/qmlformat/data/Example1.formatted.qml b/tests/auto/qml/qmlformat/data/Example1.formatted.qml
index cb8865d94e..c4aef78924 100644
--- a/tests/auto/qml/qmlformat/data/Example1.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/Example1.formatted.qml
@@ -43,7 +43,7 @@ Item {
property bool some_bool: false
// This comment is related to the property animation
- PropertyAnimation on x {
+ PropertyAnimation on x {
id: foo2
x: 3
y: x + 3
@@ -54,6 +54,7 @@ Item {
// Another orphan
// More orphans
+
property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3]
property bool something_computed: function (x) {
const PI = 3, DAYS_PER_YEAR = 365.25;
@@ -124,6 +125,7 @@ Item {
}
// Another orphan inside something_computed
+
return "foobar";
}()
@@ -133,11 +135,9 @@ Item {
// This is an orphan
// This is a cool text
- Text {
- },
+ Text {},
// This is a cool rectangle
- Rectangle {
- }
+ Rectangle {}
]
// some_read_only_bool
diff --git a/tests/auto/qml/qmlformat/data/Example1.formatted.tabs.qml b/tests/auto/qml/qmlformat/data/Example1.formatted.tabs.qml
index ef964f6f60..7cea50213a 100644
--- a/tests/auto/qml/qmlformat/data/Example1.formatted.tabs.qml
+++ b/tests/auto/qml/qmlformat/data/Example1.formatted.tabs.qml
@@ -43,7 +43,7 @@ Item {
property bool some_bool: false
// This comment is related to the property animation
- PropertyAnimation on x {
+ PropertyAnimation on x {
id: foo2
x: 3
y: x + 3
@@ -54,6 +54,7 @@ Item {
// Another orphan
// More orphans
+
property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3]
property bool something_computed: function (x) {
const PI = 3, DAYS_PER_YEAR = 365.25;
@@ -124,6 +125,7 @@ Item {
}
// Another orphan inside something_computed
+
return "foobar";
}()
@@ -133,11 +135,9 @@ Item {
// This is an orphan
// This is a cool text
- Text {
- },
+ Text {},
// This is a cool rectangle
- Rectangle {
- }
+ Rectangle {}
]
// some_read_only_bool
diff --git a/tests/auto/qml/qmlformat/data/Example1.formatted2.qml b/tests/auto/qml/qmlformat/data/Example1.formatted2.qml
index aa662a3d5f..7049686900 100644
--- a/tests/auto/qml/qmlformat/data/Example1.formatted2.qml
+++ b/tests/auto/qml/qmlformat/data/Example1.formatted2.qml
@@ -39,6 +39,7 @@ Item {
// Another orphan
// More orphans
+
property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3]
property bool some_bool: false
default property bool some_default_bool: 500 % 5 !== 0 // some_default_bool
@@ -114,6 +115,7 @@ Item {
}
// Another orphan inside something_computed
+
return "foobar";
}()
@@ -140,14 +142,12 @@ Item {
// This is an orphan
// This is a cool text
- Text {
- },
+ Text {},
// This is a cool rectangle
- Rectangle {
- }
+ Rectangle {}
]
// This comment is related to the property animation
- PropertyAnimation on x {
+ PropertyAnimation on x {
id: foo2
x: 3
y: x + 3
diff --git a/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml b/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml
index 7dfe435ac0..95b4fcf4a3 100644
--- a/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml
@@ -1,4 +1,3 @@
// This comment should be directly above Item after formatting
-Item {
-}
+Item {}
diff --git a/tests/auto/qml/qmlformat/data/arrayEndComma.formatted.qml b/tests/auto/qml/qmlformat/data/arrayEndComma.formatted.qml
new file mode 100644
index 0000000000..8ae4dd7c88
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/arrayEndComma.formatted.qml
@@ -0,0 +1,4 @@
+Item {
+ // should keep its comma
+ property var some_array_literal: [30, 20, 0.3,]
+}
diff --git a/tests/auto/qml/qmlformat/data/arrayEndComma.qml b/tests/auto/qml/qmlformat/data/arrayEndComma.qml
new file mode 100644
index 0000000000..1aec09515c
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/arrayEndComma.qml
@@ -0,0 +1,8 @@
+Item {
+ // should keep its comma
+ property var some_array_literal: [
+ 30,
+ 20,
+ 0.3,
+ ]
+}
diff --git a/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml
new file mode 100644
index 0000000000..ac4cf97881
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml
@@ -0,0 +1,10 @@
+import QtQuick
+
+Item {
+ Component.onCompleted: {
+ let f = ([]) => {};
+ let g = ([a]) => {};
+ let h = ([a, b]) => {};
+ let i = ([a, ...b]) => {};
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml
new file mode 100644
index 0000000000..2a47b2f152
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml
@@ -0,0 +1,8 @@
+import QtQuick
+
+Item { Component.onCompleted: { let f = ([]) => {};
+ let g = ([a]) => {};
+ let h = ([a, b]) => {};
+ let i = ([a, ...b]) => {};
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/blanklinesAfterComment.formatted.qml b/tests/auto/qml/qmlformat/data/blanklinesAfterComment.formatted.qml
new file mode 100644
index 0000000000..071e3bc69f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/blanklinesAfterComment.formatted.qml
@@ -0,0 +1,12 @@
+/* comment with spaces */
+
+/*
+ another comment
+ */
+//
+
+// another comment /*test */
+
+import QtQml
+
+QtObject {}
diff --git a/tests/auto/qml/qmlformat/data/blanklinesAfterComment.qml b/tests/auto/qml/qmlformat/data/blanklinesAfterComment.qml
new file mode 100644
index 0000000000..c99415aeed
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/blanklinesAfterComment.qml
@@ -0,0 +1,15 @@
+/* comment with spaces */
+
+/*
+ another comment
+ */
+//
+
+
+// another comment /*test */
+
+
+
+import QtQml
+
+QtObject {}
diff --git a/tests/auto/qml/qmlformat/data/class.formatted.js b/tests/auto/qml/qmlformat/data/class.formatted.js
new file mode 100644
index 0000000000..eeb1faf64e
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/class.formatted.js
@@ -0,0 +1,5 @@
+class Person {
+ constructor(name) {
+ this._name = name;
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/class.js b/tests/auto/qml/qmlformat/data/class.js
new file mode 100644
index 0000000000..116061d515
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/class.js
@@ -0,0 +1 @@
+class Person{constructor(name){this._name = name;}}
diff --git a/tests/auto/qml/qmlformat/data/commentInEnum.formatted.qml b/tests/auto/qml/qmlformat/data/commentInEnum.formatted.qml
new file mode 100644
index 0000000000..583c315c4b
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/commentInEnum.formatted.qml
@@ -0,0 +1,11 @@
+import QtQml
+
+QtObject {
+ // This to enum
+ enum Foo {
+ A = 3, // This is A
+ B, // This is B
+ C = 4, // This is C
+ D // This is D
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/commentInEnum.qml b/tests/auto/qml/qmlformat/data/commentInEnum.qml
new file mode 100644
index 0000000000..3a1b15d278
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/commentInEnum.qml
@@ -0,0 +1,12 @@
+import QtQml
+
+QtObject {
+ // This to enum
+ enum Foo {
+ A = 3, // This is A
+ B, // This is B
+ C = 4, // This is C
+ D // This is D
+ }
+
+}
diff --git a/tests/auto/qml/qmlformat/data/commentInQmlObject.formatted.qml b/tests/auto/qml/qmlformat/data/commentInQmlObject.formatted.qml
new file mode 100644
index 0000000000..749dc65b7c
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/commentInQmlObject.formatted.qml
@@ -0,0 +1,4 @@
+import QtQml
+
+// hello world
+QtObject {}
diff --git a/tests/auto/qml/qmlformat/data/commentInQmlObject.qml b/tests/auto/qml/qmlformat/data/commentInQmlObject.qml
new file mode 100644
index 0000000000..9aca637e4f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/commentInQmlObject.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ // hello world
+}
diff --git a/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml
new file mode 100644
index 0000000000..0bfcc58179
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml
@@ -0,0 +1,24 @@
+import QtQml
+
+QtObject {
+
+ function evil({
+ hello = "world",
+ x = 42
+ }, [n = 42, m = 43, o = 44], {
+ destructuring,
+ is = {
+ a,
+ lot,
+ of
+ },
+ fun = 42
+ } = {
+ destructuring: 123,
+ is: {
+ x: 123
+ },
+ fun: 456
+ }) {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml
new file mode 100644
index 0000000000..f41661ed67
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+QtObject {
+
+ function evil({ hello = "world", x = 42 },
+ [n = 42, m = 43, o = 44],
+ { destructuring, is = {a, lot, of}, fun = 42 } = {destructuring : 123, is : {x : 123}, fun : 456}) {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/directives.formatted.js b/tests/auto/qml/qmlformat/data/directives.formatted.js
new file mode 100644
index 0000000000..3d0a4db544
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/directives.formatted.js
@@ -0,0 +1,8 @@
+.pragma library
+.import "fun.js" as Fun
+.import Qt.test 1.0 as JsQtTest
+.import Qt.Quick as Test
+
+Fun.begin();
+Test.do_stuff();
+JsQtTest.do_stuff();
diff --git a/tests/auto/qml/qmlformat/data/directives.js b/tests/auto/qml/qmlformat/data/directives.js
new file mode 100644
index 0000000000..b8e1b785ac
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/directives.js
@@ -0,0 +1,9 @@
+
+.pragma library
+
+.import "fun.js" as Fun
+.import Qt.test 1.0 as JsQtTest
+
+
+.import Qt.Quick as Test
+Fun.begin();Test.do_stuff();JsQtTest.do_stuff();
diff --git a/tests/auto/qml/qmlformat/data/directivesWithComments.formatted.js b/tests/auto/qml/qmlformat/data/directivesWithComments.formatted.js
new file mode 100644
index 0000000000..c130f72453
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/directivesWithComments.formatted.js
@@ -0,0 +1,6 @@
+.pragma library // use as library
+/*
+ Fun is necessary
+ */
+.import "fun.js" as Fun
+.import Qt.test 1.0 as JsQtTest // yet another comment not to be lost
diff --git a/tests/auto/qml/qmlformat/data/directivesWithComments.js b/tests/auto/qml/qmlformat/data/directivesWithComments.js
new file mode 100644
index 0000000000..7206bb27ed
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/directivesWithComments.js
@@ -0,0 +1,8 @@
+
+.pragma library // use as library
+
+/*
+ Fun is necessary
+ */
+.import "fun.js" as Fun
+.import Qt.test 1.0 as JsQtTest // yet another comment not to be lost
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
index 0c7a2829c9..8eaac71178 100644
--- a/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
@@ -1,13 +1,15 @@
Item {
- property var test: [{
+ property var test: [
+ {
// Testing
"foo": "bar"
- }]
+ }
+ ]
onTestChanged: {
fooBar(test, {
- // Testing
- "foo": "bar"
- });
+ // Testing
+ "foo": "bar"
+ });
}
}
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
index 1797834879..2d2b4b6705 100644
--- a/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
@@ -1,8 +1,10 @@
Item {
- property var test: [{
-// Testing
+ property var test: [
+ {
+ // Testing
"foo": "bar"
- }]
+ }
+ ]
onTestChanged: {
fooBar(test, {
diff --git a/tests/auto/qml/qmlformat/data/ecmaScriptClassInQml.formatted.qml b/tests/auto/qml/qmlformat/data/ecmaScriptClassInQml.formatted.qml
index edbb12c6e6..de6a23f9c7 100644
--- a/tests/auto/qml/qmlformat/data/ecmaScriptClassInQml.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/ecmaScriptClassInQml.formatted.qml
@@ -4,11 +4,13 @@ Item {
function f() {
var count = 0;
+
class Person {
constructor(name){
this._name = name;
}
}
+
class Employee extends Person {
constructor(name, age){
super(name);
diff --git a/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.formatted.qml b/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.formatted.qml
new file mode 100644
index 0000000000..f41942e054
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.formatted.qml
@@ -0,0 +1,13 @@
+import QtQml
+
+QtObject {
+
+ function patron(a, ...b) {
+ }
+
+ function patron1(a, ...[b, ...args]) {
+ }
+
+ function patron2(...{}) {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.qml b/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.qml
new file mode 100644
index 0000000000..28364f29c9
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/ellipsisFunctionArgument.qml
@@ -0,0 +1,11 @@
+import QtQml
+
+QtObject {
+
+ function patron(a, ...b) {
+ }
+
+ function patron1(a, ...[b, ...args]) {}
+
+ function patron2(...{}) {}
+} \ No newline at end of file
diff --git a/tests/auto/qml/qmlformat/data/enumWithValues.formatted.qml b/tests/auto/qml/qmlformat/data/enumWithValues.formatted.qml
new file mode 100644
index 0000000000..bbf978936f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/enumWithValues.formatted.qml
@@ -0,0 +1,12 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQuick
+
+Rectangle {
+ enum AxisAlignment {
+ Bottom = 0,
+ Left = 1,
+ Right = 2
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/enumWithValues.qml b/tests/auto/qml/qmlformat/data/enumWithValues.qml
new file mode 100644
index 0000000000..2dbe7fbac5
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/enumWithValues.qml
@@ -0,0 +1,12 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQuick
+
+Rectangle{
+enum AxisAlignment{
+Bottom = 0,
+Left = 1,
+Right = 2
+}
+}
diff --git a/tests/auto/qml/qmlformat/data/escapeChars.formatted.qml b/tests/auto/qml/qmlformat/data/escapeChars.formatted.qml
new file mode 100644
index 0000000000..3f6807834f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/escapeChars.formatted.qml
@@ -0,0 +1,16 @@
+import QtQuick
+
+Item {
+ x: {
+ const s = "\"";
+ let a = {
+ "\"": "\\"
+ };
+
+ let patron = {
+ "\\\"\n\n": "\?\?\\\"",
+ "": "",
+ "\'\"\n": 1
+ };
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/escapeChars.qml b/tests/auto/qml/qmlformat/data/escapeChars.qml
new file mode 100644
index 0000000000..c82ff3119e
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/escapeChars.qml
@@ -0,0 +1,16 @@
+import QtQuick
+
+Item {
+ x: {
+ const s = "\""
+ let a = {
+ "\"": "\\"
+ };
+
+ let patron = {
+ "\\\"\n\n" : "\?\?\\\"","": "", "\'\"\n":1
+ };
+
+
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/esm.formatted.mjs b/tests/auto/qml/qmlformat/data/esm.formatted.mjs
new file mode 100644
index 0000000000..f0b3fd7753
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/esm.formatted.mjs
@@ -0,0 +1,44 @@
+//Imports
+import defaultExport from "module-name";
+import * as name from "module-name";
+import { export1 } from "module-name";
+import { export1 as alias1 } from "module-name";
+import { default as alias } from "module-name";
+import { export1, export2 } from "module-name";
+import { export1, export2 as alias2 } from "module-name";
+import defaultExport, { export1, a } from "module-name";
+import defaultExport, * as name from "module-name";
+import "module-name";
+
+// Exporting declarations
+export let name1, name2; // also var
+export const name1 = 1, name2 = 2; // also var, let
+export function functionName() {}
+export class ClassName {
+ constructor(h){
+ this.h = h;
+ }
+}
+export function* generatorFunctionName() {}
+export const {
+ name1,
+ name2: bar
+} = o;
+export const [name1, name2] = array;
+
+// Export list
+export { name1, nameN };
+export { variable1 as name1, variable2 as name2, nameN };
+export { name1 as default };
+
+// Default exports
+export default function* generatorFunctionName() {
+ return 1;
+}
+
+// Aggregating modules
+export * from "module-name";
+export { name1, nameN } from "module-name";
+export { import1 as name1, import2 as name2, nameN } from "module-name";
+export { default } from "module-name";
+export { default as name1 } from "module-name";
diff --git a/tests/auto/qml/qmlformat/data/esm.mjs b/tests/auto/qml/qmlformat/data/esm.mjs
new file mode 100644
index 0000000000..83e22fdedd
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/esm.mjs
@@ -0,0 +1,33 @@
+//Imports
+import defaultExport from "module-name";
+import * as name from "module-name"
+import {export1} from "module-name";
+import { export1 as alias1 } from "module-name";
+import { default as alias } from "module-name"
+import { export1, export2 } from "module-name";
+import {export1,export2 as alias2} from "module-name";
+import defaultExport,{export1,a} from "module-name"
+import defaultExport, * as name from "module-name";
+import "module-name";
+
+
+// Exporting declarations
+export let name1,name2; // also var
+export const name1=1,name2=2 // also var, let
+export function functionName() {}
+export class ClassName{constructor(h){this.h=h;}}
+export function* generatorFunctionName() {}
+export const {name1, name2: bar}=o;export const [name1,name2]=array
+
+// Export list
+export {name1,nameN};export {variable1 as name1,variable2 as name2,nameN }
+export {name1 as default};
+
+// Default exports
+export default function* generatorFunctionName() {return 1;}
+
+// Aggregating modules
+export * from "module-name";
+export { name1,nameN} from "module-name"
+export { import1 as name1, import2 as name2,nameN } from "module-name";export { default, } from "module-name";
+export { default as name1 } from "module-name";
diff --git a/tests/auto/qml/qmlformat/data/filesOption/valid1.formatted.qml b/tests/auto/qml/qmlformat/data/filesOption/valid1.formatted.qml
new file mode 100644
index 0000000000..a995f0479f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/filesOption/valid1.formatted.qml
@@ -0,0 +1,10 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQml
+
+QtObject {
+ property int a
+ function aa() {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/filesOption/valid1.qml b/tests/auto/qml/qmlformat/data/filesOption/valid1.qml
new file mode 100644
index 0000000000..8aef366bd9
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/filesOption/valid1.qml
@@ -0,0 +1,9 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQml
+
+QtObject {
+property int a
+function aa(){}
+} \ No newline at end of file
diff --git a/tests/auto/qml/qmlformat/data/filesOption/valid2.formatted.qml b/tests/auto/qml/qmlformat/data/filesOption/valid2.formatted.qml
new file mode 100644
index 0000000000..a995f0479f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/filesOption/valid2.formatted.qml
@@ -0,0 +1,10 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQml
+
+QtObject {
+ property int a
+ function aa() {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/filesOption/valid2.qml b/tests/auto/qml/qmlformat/data/filesOption/valid2.qml
new file mode 100644
index 0000000000..f2cb636c00
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/filesOption/valid2.qml
@@ -0,0 +1,9 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQml
+
+QtObject {
+ property int a
+ function aa() {}
+}
diff --git a/tests/auto/qml/qmlformat/data/forOf.formatted.qml b/tests/auto/qml/qmlformat/data/forOf.formatted.qml
index fa9ff9c631..0cc4f9fecd 100644
--- a/tests/auto/qml/qmlformat/data/forOf.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/forOf.formatted.qml
@@ -3,6 +3,7 @@ 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)
diff --git a/tests/auto/qml/qmlformat/data/functionsSpacing.formatted.qml b/tests/auto/qml/qmlformat/data/functionsSpacing.formatted.qml
index d452ba2b8c..91f520b5fc 100644
--- a/tests/auto/qml/qmlformat/data/functionsSpacing.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/functionsSpacing.formatted.qml
@@ -6,8 +6,7 @@ Item {
}
function test2() {
}
- Button {
- }
+ Button {}
function test4() {
}
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..6613becaca
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/importStatements.formatted.qml
@@ -0,0 +1,8 @@
+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/javascriptBlock.formatted.qml b/tests/auto/qml/qmlformat/data/javascriptBlock.formatted.qml
new file mode 100644
index 0000000000..09ab9454e1
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/javascriptBlock.formatted.qml
@@ -0,0 +1,6 @@
+Item {
+ block1: {
+ console.log("Hello, world!");
+ }
+ emptyBlock: {}
+}
diff --git a/tests/auto/qml/qmlformat/data/javascriptBlock.qml b/tests/auto/qml/qmlformat/data/javascriptBlock.qml
new file mode 100644
index 0000000000..1665c81f42
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/javascriptBlock.qml
@@ -0,0 +1,5 @@
+Item {
+ block1: {console.log("Hello, world!");}
+ emptyBlock: {
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.formatted.js b/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.formatted.js
new file mode 100644
index 0000000000..62a5e36f5e
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.formatted.js
@@ -0,0 +1,6 @@
+var b = function () {
+ var a = 1;
+ for (var ii = 1; ii < 10; ++ii) {
+ a = a * ii;
+ }
+};
diff --git a/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.js b/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.js
new file mode 100644
index 0000000000..0155cff7f9
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaFunctionWithLoop.js
@@ -0,0 +1 @@
+var b=function(){var a=1;for(var ii=1;ii<10;++ii){a=a*ii;}}
diff --git a/tests/auto/qml/qmlformat/data/lambdaWithIfElse.formatted.js b/tests/auto/qml/qmlformat/data/lambdaWithIfElse.formatted.js
new file mode 100644
index 0000000000..3bc7f683c4
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaWithIfElse.formatted.js
@@ -0,0 +1,7 @@
+var f = function () {
+ if (true) {
+ console.log("true");
+ } else {
+ console.log("false");
+ }
+};
diff --git a/tests/auto/qml/qmlformat/data/lambdaWithIfElse.js b/tests/auto/qml/qmlformat/data/lambdaWithIfElse.js
new file mode 100644
index 0000000000..aaf731e5f0
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaWithIfElse.js
@@ -0,0 +1 @@
+var f = function(){if(true){ console.log("true");} else {console.log("false");}}
diff --git a/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.formatted.js b/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.formatted.js
new file mode 100644
index 0000000000..99db6fb372
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.formatted.js
@@ -0,0 +1,9 @@
+var l = function () {
+ var nl = function () {
+ if (true) {
+ console.log("true");
+ } else {
+ console.log("false");
+ }
+ };
+};
diff --git a/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.js b/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.js
new file mode 100644
index 0000000000..23ae087b04
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/lambdaWithIfElseInsideLambda.js
@@ -0,0 +1 @@
+var l = function(){var nl = function(){if(true){console.log("true");}else{console.log("false");}};};
diff --git a/tests/auto/qml/qmlformat/data/messyIfStatement.formatted.js b/tests/auto/qml/qmlformat/data/messyIfStatement.formatted.js
new file mode 100644
index 0000000000..cd7d75314c
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/messyIfStatement.formatted.js
@@ -0,0 +1,4 @@
+if (((typeof ezJsu !== 'undefined') && ezJsu === true) || ((typeof _ez_sa !== 'undefined') && _ez_sa === true)) {
+ a.defaultStoreUrl = '//g.ezoic.net/ezoic/imp.gif';
+ a.defaultStoreA = '//g.ezoic.net/ezoic/i.gif';// Single Line Comments here
+}
diff --git a/tests/auto/qml/qmlformat/data/messyIfStatement.js b/tests/auto/qml/qmlformat/data/messyIfStatement.js
new file mode 100644
index 0000000000..cdd4c7bd9d
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/messyIfStatement.js
@@ -0,0 +1,2 @@
+if (((typeof ezJsu!=='undefined')&&ezJsu===true)||((typeof _ez_sa !=='undefined')&&_ez_sa === true)) {a.defaultStoreUrl='//g.ezoic.net/ezoic/imp.gif';a.defaultStoreA ='//g.ezoic.net/ezoic/i.gif';// Single Line Comments here
+}
diff --git a/tests/auto/qml/qmlformat/data/mini_esm.formattedTabs.mjs b/tests/auto/qml/qmlformat/data/mini_esm.formattedTabs.mjs
new file mode 100644
index 0000000000..37f8ccb698
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/mini_esm.formattedTabs.mjs
@@ -0,0 +1,20 @@
+//Imports
+import defaultExport from "module-name";
+import "module-name";
+export class ClassName {
+ constructor(h){
+ this.h = h;
+ }
+}
+export const {
+ n1,
+ n3,
+ n4,
+ name2: bar
+} = o;
+export const [name1, name2] = array;
+function stuff() {
+ var l = () => {
+ 1 + 1;
+ };
+}
diff --git a/tests/auto/qml/qmlformat/data/mini_esm.mjs b/tests/auto/qml/qmlformat/data/mini_esm.mjs
new file mode 100644
index 0000000000..9d6c2406dc
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/mini_esm.mjs
@@ -0,0 +1,3 @@
+//Imports
+import defaultExport from "module-name";import "module-name";export class ClassName{constructor(h){this.h=h;}}
+export const {n1,n3,n4,name2:bar}=o;export const [name1,name2]=array;function stuff(){var l=()=>{1+1};};
diff --git a/tests/auto/qml/qmlformat/data/multilineComment.formatted.qml b/tests/auto/qml/qmlformat/data/multilineComment.formatted.qml
index 45d04c5887..46e3e963ea 100644
--- a/tests/auto/qml/qmlformat/data/multilineComment.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/multilineComment.formatted.qml
@@ -1,11 +1,9 @@
Item {
- Item {
- }
+ Item {}
/* This is a multiline comment.
it should stay attached to Commented instead of getting orphaned.
*/
// This should also stick to Commented
- Commented {
- }
+ Commented {}
}
diff --git a/tests/auto/qml/qmlformat/data/nestedFunctions.formatted.qml b/tests/auto/qml/qmlformat/data/nestedFunctions.formatted.qml
index 5536ecf513..fc1915f647 100644
--- a/tests/auto/qml/qmlformat/data/nestedFunctions.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/nestedFunctions.formatted.qml
@@ -1,11 +1,13 @@
Item {
function a() {
function nested() {}
+
foo();
}
function b() {
function nested() {}
+
bar();
}
}
diff --git a/tests/auto/qml/qmlformat/data/nestedIf.formatted.qml b/tests/auto/qml/qmlformat/data/nestedIf.formatted.qml
index 4ff5a40a23..ebb125f36d 100644
--- a/tests/auto/qml/qmlformat/data/nestedIf.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/nestedIf.formatted.qml
@@ -26,6 +26,7 @@ Item {
x();
}
}
+
if (x && y)
if (x < y)
return 0;
diff --git a/tests/auto/qml/qmlformat/data/objectDestructuring.formatted.qml b/tests/auto/qml/qmlformat/data/objectDestructuring.formatted.qml
new file mode 100644
index 0000000000..94e97076b1
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/objectDestructuring.formatted.qml
@@ -0,0 +1,137 @@
+import QtQml
+
+QtObject {
+
+ function set1() {
+ const array = [1, 2, 3, 4];
+ const [a, b] = [1, 2];
+ const [aa, , bb] = array;
+ const [aaa = 23, bbb] = array;
+ const [a1, b1, ...rest1] = array;
+ const [a2, , b2, ...rest2] = array;
+ const [a3, b3, ...{
+ pop,
+ push
+ }] = array;
+ const [a4, b4, ...[c, d]] = array;
+
+ const obj = {
+ _a: 1,
+ _b: 2
+ };
+ const {
+ a5,
+ b5
+ } = obj;
+ const {
+ a6: a_,
+ b6: b1_
+ } = obj;
+ const {
+ a7: a11 = 4,
+ b11 = 34,
+ c1: b111,
+ d1
+ } = obj;
+ let key = a;
+ const {
+ [key]: a___
+ } = obj;
+ }
+
+ function set2() {
+ // declare first
+ let a, b, a1, b1, c, d, rest, pop, push;
+ const array = [1, 2, 3, 4];
+ [a, b] = array;
+ [a, , b] = array;
+ [a = aDefault, b] = array;
+ [a, b, ...rest] = array;
+ [a, , b, ...rest] = array;
+ [a, b, ...{
+ pop,
+ push
+ }] = array;
+ [a, b, ...[c, d]] = array;
+
+ const obj = {
+ _a: 1,
+ _b: 2
+ };
+ ({
+ a,
+ b
+ } = obj); // brackets are required
+ ({
+ a: a1,
+ b: b1
+ } = obj);
+
+ const complicatedObject = {
+ a: 1,
+ b: {
+ c: 2,
+ d: {
+ e: 3,
+ f: [4, 5, 6]
+ }
+ },
+ g: [7, 8, 9]
+ };
+
+ const {
+ patron,
+ b: {
+ mafik,
+ d: {
+ e,
+ f: [, secondF, ...restF]
+ }
+ },
+ g: [firstG, ...restG]
+ } = complicatedObject;
+ }
+
+ Component.onCompleted: {
+ const myFunction = myLambda => {
+ const myObject = {
+ a: 1,
+ b: {
+ c: 2,
+ d: [3, 4, 5]
+ },
+ e: {
+ f: 6,
+ g: {
+ h: 7,
+ i: [8, 9, 10]
+ }
+ }
+ };
+
+ myLambda(myObject);
+ };
+
+ myFunction(({
+ a,
+ b: {
+ c,
+ d: [firstD]
+ },
+ e: {
+ f,
+ g: {
+ h,
+ i: [, secondI]
+ }
+ }
+ }) => {
+ console.log(a); // 1
+ console.log(c); // 2
+ console.log(firstD); // 3
+ console.log(f); // 6
+ console.log(h); // 7
+ console.log(secondI); // 9
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/objectDestructuring.qml b/tests/auto/qml/qmlformat/data/objectDestructuring.qml
new file mode 100644
index 0000000000..0487153125
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/objectDestructuring.qml
@@ -0,0 +1,77 @@
+import QtQml
+
+QtObject {
+
+ function set1() {
+ const array = [1,2,3,4];
+ const [a, b] = [1,2];
+ const [aa, , bb] = array;
+ const [aaa = 23, bbb] = array;
+ const [a1, b1, ...rest1] = array;
+ const [a2, , b2, ...rest2] = array;
+ const [a3, b3, ...{ pop, push }] = array;
+ const [a4, b4, ...[c, d]] = array;
+
+ const obj = {_a:1,_b:2};
+ const { a5, b5 } = obj;
+ const { a6: a_, b6: b1_ } = obj;
+ const { a7: a11 = 4, b11 = 34, c1: b111, d1 } = obj;
+ let key = a;
+ const { [key]: a___ } = obj;
+ }
+
+ function set2() {
+ // declare first
+ let a, b, a1, b1, c, d, rest, pop, push;
+ const array = [1,2,3,4];
+ [a, b] = array;
+ [a, , b] = array;
+ [a = aDefault, b] = array;
+ [a, b, ...rest] = array;
+ [a, , b, ...rest] = array;
+ [a, b, ...{ pop, push }] = array;
+ [a, b, ...[c, d]] = array;
+
+ const obj = {_a:1,_b:2};
+ ({ a, b } = obj); // brackets are required
+ ({ a: a1, b: b1 } = obj);
+
+ const complicatedObject = {
+ a: 1,
+ b: {
+ c: 2,
+ d: {
+ e: 3,
+ f: [4, 5, 6]
+ }
+ },
+ g: [7, 8, 9]
+ };
+
+ const { patron, b: { mafik, d: { e, f: [ , secondF, ...restF ] } }, g: [ firstG, ...restG ] } = complicatedObject;
+ }
+
+ Component.onCompleted: {
+ const myFunction = (myLambda) => {
+ const myObject = {
+ a: 1,
+ b: {c: 2, d: [3, 4, 5] }, e: {
+ f: 6,
+ g: { h: 7, i: [8, 9, 10]
+ }
+ }
+ };
+
+ myLambda(myObject);
+ };
+
+ myFunction(({ a, b: { c, d: [ firstD ] }, e: { f, g: { h, i: [ , secondI ] } } }) => {
+ console.log(a); // 1
+ console.log(c); // 2
+ console.log(firstD); // 3
+ console.log(f); // 6
+ console.log(h); // 7
+ console.log(secondI); // 9
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/objectsSpacing.formatted.qml b/tests/auto/qml/qmlformat/data/objectsSpacing.formatted.qml
index bd0406e595..df26a9b599 100644
--- a/tests/auto/qml/qmlformat/data/objectsSpacing.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/objectsSpacing.formatted.qml
@@ -1,6 +1,9 @@
Item {
+ Button {}
+
Button {
+ id: foo
}
height: 360
diff --git a/tests/auto/qml/qmlformat/data/objectsSpacing.qml b/tests/auto/qml/qmlformat/data/objectsSpacing.qml
index 6adc89778c..0239b05145 100644
--- a/tests/auto/qml/qmlformat/data/objectsSpacing.qml
+++ b/tests/auto/qml/qmlformat/data/objectsSpacing.qml
@@ -3,6 +3,10 @@ Item {
Button {
}
+ Button {
+ id: foo
+ }
+
height: 360
width: 360
diff --git a/tests/auto/qml/qmlformat/data/pragma.formatted.js b/tests/auto/qml/qmlformat/data/pragma.formatted.js
new file mode 100644
index 0000000000..3f57e537ac
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/pragma.formatted.js
@@ -0,0 +1,4 @@
+"use strict";
+{
+ function f() {}
+}
diff --git a/tests/auto/qml/qmlformat/data/pragma.formatted.qml b/tests/auto/qml/qmlformat/data/pragma.formatted.qml
new file mode 100644
index 0000000000..143db39888
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/pragma.formatted.qml
@@ -0,0 +1,8 @@
+pragma Singleton
+pragma ComponentBehavior: Bound
+pragma FunctionSignatureBehavior: Enforced
+pragma ValueTypeBehavior: Copy, Addressable
+
+import QtQml
+
+QtObject {}
diff --git a/tests/auto/qml/qmlformat/data/pragma.js b/tests/auto/qml/qmlformat/data/pragma.js
new file mode 100644
index 0000000000..b81d52d853
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/pragma.js
@@ -0,0 +1 @@
+"use strict";{function f(){}}
diff --git a/tests/auto/qml/qmlformat/data/pragma.qml b/tests/auto/qml/qmlformat/data/pragma.qml
new file mode 100644
index 0000000000..7469277395
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/pragma.qml
@@ -0,0 +1,8 @@
+pragma Singleton
+ pragma ComponentBehavior: Bound
+ pragma FunctionSignatureBehavior: Enforced
+pragma ValueTypeBehavior: Copy, Addressable
+
+import QtQml
+
+QtObject {}
diff --git a/tests/auto/qml/qmlformat/data/propertyNames.formatted.qml b/tests/auto/qml/qmlformat/data/propertyNames.formatted.qml
index 94b5877957..9214014889 100644
--- a/tests/auto/qml/qmlformat/data/propertyNames.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/propertyNames.formatted.qml
@@ -3,11 +3,11 @@ Item {
var copiedItem = "copied value";
var computedItem = "computedName";
var obj = {
- "identifierName": "identifier value",
+ identifierName: "identifier value",
"string name": "string value",
- "Infinity": "numeric value",
+ Infinity: "numeric value",
[computedItem]: "computed value",
- "copiedItem": copiedItem
+ copiedItem
};
}
}
diff --git a/tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml b/tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml
index b9bcc34e8c..767bfe7e61 100644
--- a/tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml
+++ b/tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml
@@ -1 +1 @@
-/* This file is licensed under the not a license license 1. You may not comply 2. Goodbye */ // Importing this is very important import QtQuick 5.15 // Muddling the waters! import QtQuick.Models 3.14 as muddle // Importing that is important too import Z import That import This // THIS IS VERY IMPORTANT! import Y import X.Z import X.Y import A.LLOHA import A.B.B.A // This comment is related to Item Item { // This to id // Also id. (line 2) // This is the third id // fourth id comment id: foo // This to enum enum Foo { A = 3, // This is A B, // This is B C = 4, // This is C D // This is D } // Orphan comment // Another orphan // More orphans property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3] property bool some_bool: false default property bool some_default_bool: 500 % 5 !== 0 // some_default_bool // some_read_only_bool readonly property bool some_read_only_bool: Math.sin(3) && (aFunc()[30] + 5) | 2 != 0 property bool something_computed: function (x) { const PI = 3, DAYS_PER_YEAR = 365.25; var x = 3 + 2; x["bla"] = 50; // This is an orphan inside something_computed // Are these getting duplicated? // This one to var few! var few = new WhatEver(); x += Math.sin(3); x--; --x; x++; ++x; for (var x = 0; x < 100; x++) { x++; console.log("Foo"); } for (var x in [3, 2, 1]) { y++; console.log("Bar"); } while (true) { console.log("Wee"); } with (foo) { bar; x += 5; } // This is related to with! x3: do { console.log("Hello"); } while (3 == 0) try { dangerous(); } catch (e) { console.log(e); } finally { console.log("What else?"); } switch (x) { case 0: x = 1; break; case 1: x = 5; break; case 4: x = 100; break; } if (x == 50) { console.log("true"); } else if (x == 50) { console.log("other thing"); } else { console.log("false"); } if (x == 50) { console.log("true"); } else if (x == 50) { console.log("other thing"); x--; } else { console.log("false"); } // Another orphan inside something_computed return "foobar"; }() signal say(string name, bool caps) // This one to aFunc() function aFunc() { var x = 3; return x; } x: 3 // Very cool myFavouriteThings: [ // This is an orphan // This is a cool text Text { }, // This is a cool rectangle Rectangle { } ] // This comment is related to the property animation PropertyAnimation on x { id: foo2 x: 3 y: x + 3 } Component.onCompleted: console.log("Foo!") Text { required property string batman signal boo(int count, int times, real duration) text: "Bla" } } \ No newline at end of file
+/* This file is licensed under the not a license license 1. You may not comply 2. Goodbye */ // Importing this is very important import QtQuick 5.15 // Muddling the waters! import QtQuick.Models 3.14 as muddle // Importing that is important too import Z import That import This // THIS IS VERY IMPORTANT! import Y import X.Z import X.Y import A.LLOHA import A.B.B.A // This comment is related to Item Item { // This to id // Also id. (line 2) // This is the third id // fourth id comment id: foo // This to enum enum Foo { A = 3, // This is A B, // This is B C = 4, // This is C D // This is D } // Orphan comment // Another orphan // More orphans property variant some_array_literal: [30, 20, Math["PI"], [4, 3, 2], "foo", 0.3] property bool some_bool: false default property bool some_default_bool: 500 % 5 !== 0 // some_default_bool // some_read_only_bool readonly property bool some_read_only_bool: Math.sin(3) && (aFunc()[30] + 5) | 2 != 0 property bool something_computed: function (x) { const PI = 3, DAYS_PER_YEAR = 365.25; var x = 3 + 2; x["bla"] = 50; // This is an orphan inside something_computed // Are these getting duplicated? // This one to var few! var few = new WhatEver(); x += Math.sin(3); x--; --x; x++; ++x; for (var x = 0; x < 100; x++) { x++; console.log("Foo"); } for (var x in [3, 2, 1]) { y++; console.log("Bar"); } while (true) { console.log("Wee"); } with (foo) { bar; x += 5; } // This is related to with! x3: do { console.log("Hello"); } while (3 == 0) try { dangerous(); } catch (e) { console.log(e); } finally { console.log("What else?"); } switch (x) { case 0: x = 1; break; case 1: x = 5; break; case 4: x = 100; break; } if (x == 50) { console.log("true"); } else if (x == 50) { console.log("other thing"); } else { console.log("false"); } if (x == 50) { console.log("true"); } else if (x == 50) { console.log("other thing"); x--; } else { console.log("false"); } // Another orphan inside something_computed return "foobar"; }() signal say(string name, bool caps) // This one to aFunc() function aFunc() { var x = 3; return x; } x: 3 // Very cool myFavouriteThings: [ // This is an orphan // This is a cool text Text { }, // This is a cool rectangle Rectangle { } ] // This comment is related to the property animation PropertyAnimation on x { id: foo2 x: 3 y: x + 3 } Component.onCompleted: console.log("Foo!") Text { required property string batman signal boo(int count, int times, real duration) text: "Bla" } } \ No newline at end of file
diff --git a/tests/auto/qml/qmlformat/data/simpleJSStatement.formatted.js b/tests/auto/qml/qmlformat/data/simpleJSStatement.formatted.js
new file mode 100644
index 0000000000..fbdec1038c
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleJSStatement.formatted.js
@@ -0,0 +1 @@
+let v = 1;
diff --git a/tests/auto/qml/qmlformat/data/simpleJSStatement.js b/tests/auto/qml/qmlformat/data/simpleJSStatement.js
new file mode 100644
index 0000000000..d954a87fc0
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleJSStatement.js
@@ -0,0 +1 @@
+let v=1;
diff --git a/tests/auto/qml/qmlformat/data/simpleLoop.formatted.js b/tests/auto/qml/qmlformat/data/simpleLoop.formatted.js
new file mode 100644
index 0000000000..435fc145bf
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleLoop.formatted.js
@@ -0,0 +1,4 @@
+var a = 1;
+for (var ii = 1; ii < 10; ++ii) {
+ a = a * ii;
+}
diff --git a/tests/auto/qml/qmlformat/data/simpleLoop.js b/tests/auto/qml/qmlformat/data/simpleLoop.js
new file mode 100644
index 0000000000..08b172991f
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleLoop.js
@@ -0,0 +1 @@
+var a=1;for(var ii=1;ii<10;++ii){a=a*ii;}
diff --git a/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.formatted.js b/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.formatted.js
new file mode 100644
index 0000000000..d5b34291e6
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.formatted.js
@@ -0,0 +1,4 @@
+function f() {
+ let a = 0;
+ return a;
+}
diff --git a/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.js b/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.js
new file mode 100644
index 0000000000..c49be5e2bd
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/simpleOnelinerJSFunc.js
@@ -0,0 +1 @@
+function f(){let a=0;return a; }
diff --git a/tests/auto/qml/qmlformat/data/statesAndTransitions.formatted.qml b/tests/auto/qml/qmlformat/data/statesAndTransitions.formatted.qml
index 40cf5068da..923f0642d7 100644
--- a/tests/auto/qml/qmlformat/data/statesAndTransitions.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/statesAndTransitions.formatted.qml
@@ -2,15 +2,12 @@ QtObject {
id: foo
states: [
- State {
- }
+ State {}
]
transitions: [
- Transition {
- }
+ Transition {}
]
// This needs to be *before* states and transitions after formatting
- Item {
- }
+ Item {}
}
diff --git a/tests/auto/qml/qmlformat/data/threeFunctions.formattedFuncSpacing.js b/tests/auto/qml/qmlformat/data/threeFunctions.formattedFuncSpacing.js
new file mode 100644
index 0000000000..592db7a02b
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/threeFunctions.formattedFuncSpacing.js
@@ -0,0 +1,11 @@
+function one() {
+ var a=1;
+}
+
+function two(a, b) {
+ console.log(a,b);
+}
+
+function three(c) {
+ var a=c;
+}
diff --git a/tests/auto/qml/qmlformat/data/threeFunctions.formattedTabs.js b/tests/auto/qml/qmlformat/data/threeFunctions.formattedTabs.js
new file mode 100644
index 0000000000..6575a9fbd8
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/threeFunctions.formattedTabs.js
@@ -0,0 +1,9 @@
+function one() {
+ var a = 1;
+}
+function two(a, b) {
+ console.log(a, b);
+}
+function three(c) {
+ var a = c;
+}
diff --git a/tests/auto/qml/qmlformat/data/threeFunctions.formattedW2.js b/tests/auto/qml/qmlformat/data/threeFunctions.formattedW2.js
new file mode 100644
index 0000000000..afcf8acf02
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/threeFunctions.formattedW2.js
@@ -0,0 +1,9 @@
+function one() {
+ var a = 1;
+}
+function two(a, b) {
+ console.log(a, b);
+}
+function three(c) {
+ var a = c;
+}
diff --git a/tests/auto/qml/qmlformat/data/threeFunctionsOneLine.js b/tests/auto/qml/qmlformat/data/threeFunctionsOneLine.js
new file mode 100644
index 0000000000..648591f221
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/threeFunctionsOneLine.js
@@ -0,0 +1 @@
+function one() {var a=1;}function two(a, b) {console.log(a,b);}function three(c){var a=c;}
diff --git a/tests/auto/qml/qmlformat/data/twoFunctions.formatted.js b/tests/auto/qml/qmlformat/data/twoFunctions.formatted.js
new file mode 100644
index 0000000000..b7414de053
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/twoFunctions.formatted.js
@@ -0,0 +1,12 @@
+function one() {
+ var a = 1;
+ if (a === true) {
+ a = 5;
+ }
+}
+
+function two(a, b) {
+ for (; b < 5; ++b) {
+ a = a * b;
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/twoFunctions.js b/tests/auto/qml/qmlformat/data/twoFunctions.js
new file mode 100644
index 0000000000..b410ebd167
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/twoFunctions.js
@@ -0,0 +1,3 @@
+function one(){var a=1;if (a===true){a=5;}}
+
+function two(a,b){for(;b<5;++b){a=a*b;}}