@@ -14,6 +14,7 @@ public class ClosureExprTests: PrettyPrintTestCase {
14
14
funcCall(closure: { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 in return s1 })
15
15
funcCall(param1: 123, closure: { s1, s2, s3 in return s1 })
16
16
funcCall(closure: { (s1: String, s2: String) -> Bool in return s1 > s2 })
17
+ funcCall(closure: { (s1: String, s2: String, s3: String, s4: String, s5: String) -> Bool in return s1 > s2 })
17
18
"""
18
19
19
20
let expected =
@@ -53,6 +54,15 @@ public class ClosureExprTests: PrettyPrintTestCase {
53
54
(s1: String, s2: String) -> Bool in
54
55
return s1 > s2
55
56
})
57
+ funcCall(closure: {
58
+ (
59
+ s1: String,
60
+ s2: String,
61
+ s3: String,
62
+ s4: String,
63
+ s5: String
64
+ ) -> Bool in return s1 > s2
65
+ })
56
66
57
67
"""
58
68
@@ -73,6 +83,7 @@ public class ClosureExprTests: PrettyPrintTestCase {
73
83
funcCall(closure: { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 in return s1 })
74
84
funcCall(param1: 123, closure: { s1, s2, s3 in return s1 })
75
85
funcCall(closure: { (s1: String, s2: String) -> Bool in return s1 > s2 })
86
+ funcCall(closure: { (s1: String, s2: String, s3: String, s4: String, s5: String) -> Bool in return s1 > s2 })
76
87
"""
77
88
78
89
let expected =
@@ -98,6 +109,12 @@ public class ClosureExprTests: PrettyPrintTestCase {
98
109
(s1: String, s2: String) -> Bool in
99
110
return s1 > s2
100
111
})
112
+ funcCall(closure: {
113
+ (
114
+ s1: String, s2: String, s3: String,
115
+ s4: String, s5: String
116
+ ) -> Bool in return s1 > s2
117
+ })
101
118
102
119
"""
103
120
@@ -113,6 +130,7 @@ public class ClosureExprTests: PrettyPrintTestCase {
113
130
funcCall(param1: 2) { $1 < $2 }
114
131
funcCall(param1: 2) { s1, s2, s3 in return s1}
115
132
funcCall(param1: 2) { s1, s2, s3, s4, s5 in return s1}
133
+ funcCall(param1: 2) { (s1: String, s2: String, s3: String, s4: String, s5: String) -> Bool in return s1 > s2 }
116
134
"""
117
135
118
136
let expected =
@@ -125,6 +143,12 @@ public class ClosureExprTests: PrettyPrintTestCase {
125
143
funcCall(param1: 2) {
126
144
s1, s2, s3, s4, s5 in return s1
127
145
}
146
+ funcCall(param1: 2) {
147
+ (
148
+ s1: String, s2: String, s3: String,
149
+ s4: String, s5: String
150
+ ) -> Bool in return s1 > s2
151
+ }
128
152
129
153
"""
130
154
@@ -345,4 +369,76 @@ public class ClosureExprTests: PrettyPrintTestCase {
345
369
346
370
assertPrettyPrintEqual ( input: input, expected: expected, linelength: 60 )
347
371
}
372
+
373
+ public func testClosureOutputGrouping( ) {
374
+ let input =
375
+ """
376
+ funcCall(closure: {
377
+ (s1: String, s2: String, s3: String) throws -> Bool in return s1 > s2
378
+ })
379
+ funcCall(closure: {
380
+ (s1: String, s2: String, s3: String) throws -> AVeryLongReturnTypeThatOverflowsFiftyColumns in return s1 > s2
381
+ })
382
+ funcCall(closure: {
383
+ () throws -> Bool in return s1 > s2
384
+ })
385
+ funcCall(closure: {
386
+ () throws -> AVeryLongReturnTypeThatOverflowsFiftyColumns in return s1 > s2
387
+ })
388
+ """
389
+
390
+ let expectedNotGroupingOutput =
391
+ """
392
+ funcCall(closure: {
393
+ (s1: String, s2: String, s3: String) throws
394
+ -> Bool in return s1 > s2
395
+ })
396
+ funcCall(closure: {
397
+ (s1: String, s2: String, s3: String) throws
398
+ -> AVeryLongReturnTypeThatOverflowsFiftyColumns
399
+ in return s1 > s2
400
+ })
401
+ funcCall(closure: {
402
+ () throws -> Bool in return s1 > s2
403
+ })
404
+ funcCall(closure: {
405
+ () throws
406
+ -> AVeryLongReturnTypeThatOverflowsFiftyColumns
407
+ in return s1 > s2
408
+ })
409
+
410
+ """
411
+
412
+ assertPrettyPrintEqual ( input: input, expected: expectedNotGroupingOutput, linelength: 50 )
413
+
414
+ let expectedKeepingOutputTogether =
415
+ """
416
+ funcCall(closure: {
417
+ (
418
+ s1: String, s2: String, s3: String
419
+ ) throws -> Bool in return s1 > s2
420
+ })
421
+ funcCall(closure: {
422
+ (
423
+ s1: String, s2: String, s3: String
424
+ ) throws
425
+ -> AVeryLongReturnTypeThatOverflowsFiftyColumns
426
+ in return s1 > s2
427
+ })
428
+ funcCall(closure: {
429
+ () throws -> Bool in return s1 > s2
430
+ })
431
+ funcCall(closure: {
432
+ () throws
433
+ -> AVeryLongReturnTypeThatOverflowsFiftyColumns
434
+ in return s1 > s2
435
+ })
436
+
437
+ """
438
+
439
+ var config = Configuration ( )
440
+ config. prioritizeKeepingFunctionOutputTogether = true
441
+ assertPrettyPrintEqual (
442
+ input: input, expected: expectedKeepingOutputTogether, linelength: 50 , configuration: config)
443
+ }
348
444
}
0 commit comments