@@ -83,6 +83,8 @@ final class CommentTests: PrettyPrintTestCase {
83
83
func testLineComments( ) {
84
84
let input =
85
85
"""
86
+ // Line Comment0
87
+
86
88
// Line Comment1
87
89
// Line Comment2
88
90
let a = 123
@@ -93,6 +95,7 @@ final class CommentTests: PrettyPrintTestCase {
93
95
// Comment 4
94
96
95
97
let reallyLongVariableName = 123 // This comment should not wrap
98
+ // and should not combine with this comment
96
99
97
100
func MyFun() {
98
101
// just a comment
@@ -135,6 +138,8 @@ final class CommentTests: PrettyPrintTestCase {
135
138
136
139
let expected =
137
140
"""
141
+ // Line Comment0
142
+
138
143
// Line Comment1
139
144
// Line Comment2
140
145
let a = 123
@@ -145,6 +150,7 @@ final class CommentTests: PrettyPrintTestCase {
145
150
// Comment 4
146
151
147
152
let reallyLongVariableName = 123 // This comment should not wrap
153
+ // and should not combine with this comment
148
154
149
155
func MyFun() {
150
156
// just a comment
@@ -208,6 +214,13 @@ final class CommentTests: PrettyPrintTestCase {
208
214
let c = [123, 456 // small comment
209
215
]
210
216
217
+ // Multiline comment
218
+ let d = [123,
219
+ // comment line 1
220
+ // comment line 2
221
+ 456
222
+ ]
223
+
211
224
/* Array comment */
212
225
let a = [456, /* small comment */
213
226
789]
@@ -236,6 +249,14 @@ final class CommentTests: PrettyPrintTestCase {
236
249
123, 456, // small comment
237
250
]
238
251
252
+ // Multiline comment
253
+ let d = [
254
+ 123,
255
+ // comment line 1
256
+ // comment line 2
257
+ 456,
258
+ ]
259
+
239
260
/* Array comment */
240
261
let a = [
241
262
456, /* small comment */
@@ -760,4 +781,55 @@ final class CommentTests: PrettyPrintTestCase {
760
781
]
761
782
)
762
783
}
784
+
785
+ func testLineWithDocLineComment( ) {
786
+ // none of these should be merged if/when there is comment formatting
787
+ let input =
788
+ """
789
+ /// Doc line comment
790
+ // Line comment
791
+ /// Doc line comment
792
+ // Line comment
793
+
794
+ // Another line comment
795
+
796
+ """
797
+ assertPrettyPrintEqual ( input: input, expected: input, linelength: 80 )
798
+ }
799
+
800
+ func testNonmergeableComments( ) {
801
+ // none of these should be merged if/when there is comment formatting
802
+ let input =
803
+ """
804
+ let x = 1 // end of line comment
805
+ //
806
+
807
+ let y = // eol comment
808
+ 1 // another
809
+ + 2 // and another
810
+
811
+ """
812
+
813
+ assertPrettyPrintEqual ( input: input, expected: input, linelength: 80 )
814
+ }
815
+
816
+ func testMergeableComments( ) {
817
+ // these examples should be merged and formatted if/when there is comment formatting
818
+ let input =
819
+ """
820
+ let z =
821
+ // one comment
822
+ // and another comment
823
+ 1 + 2
824
+
825
+ let w = [1, 2, 3]
826
+ .foo()
827
+ // this comment
828
+ // could be merged with this one
829
+ .bar()
830
+
831
+ """
832
+
833
+ assertPrettyPrintEqual ( input: input, expected: input, linelength: 80 )
834
+ }
763
835
}
0 commit comments