@@ -83,6 +83,8 @@ final class CommentTests: PrettyPrintTestCase {
8383 func testLineComments( ) {
8484 let input =
8585 """
86+ // Line Comment0
87+
8688 // Line Comment1
8789 // Line Comment2
8890 let a = 123
@@ -93,6 +95,7 @@ final class CommentTests: PrettyPrintTestCase {
9395 // Comment 4
9496
9597 let reallyLongVariableName = 123 // This comment should not wrap
98+ // and should not combine with this comment
9699
97100 func MyFun() {
98101 // just a comment
@@ -135,6 +138,8 @@ final class CommentTests: PrettyPrintTestCase {
135138
136139 let expected =
137140 """
141+ // Line Comment0
142+
138143 // Line Comment1
139144 // Line Comment2
140145 let a = 123
@@ -145,6 +150,7 @@ final class CommentTests: PrettyPrintTestCase {
145150 // Comment 4
146151
147152 let reallyLongVariableName = 123 // This comment should not wrap
153+ // and should not combine with this comment
148154
149155 func MyFun() {
150156 // just a comment
@@ -208,6 +214,13 @@ final class CommentTests: PrettyPrintTestCase {
208214 let c = [123, 456 // small comment
209215 ]
210216
217+ // Multiline comment
218+ let d = [123,
219+ // comment line 1
220+ // comment line 2
221+ 456
222+ ]
223+
211224 /* Array comment */
212225 let a = [456, /* small comment */
213226 789]
@@ -236,6 +249,14 @@ final class CommentTests: PrettyPrintTestCase {
236249 123, 456, // small comment
237250 ]
238251
252+ // Multiline comment
253+ let d = [
254+ 123,
255+ // comment line 1
256+ // comment line 2
257+ 456,
258+ ]
259+
239260 /* Array comment */
240261 let a = [
241262 456, /* small comment */
@@ -760,4 +781,55 @@ final class CommentTests: PrettyPrintTestCase {
760781 ]
761782 )
762783 }
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+ }
763835}
0 commit comments