File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed
Sources/SwiftFormatPrettyPrint
Tests/SwiftFormatPrettyPrintTests Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -526,7 +526,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
526
526
527
527
override func visit( _ node: AsExprSyntax ) {
528
528
before ( node. asTok, tokens: . space)
529
- after ( node. asTok , tokens: . break)
529
+ before ( node. typeName . firstToken , tokens: . break)
530
530
super. visit ( node)
531
531
}
532
532
Original file line number Diff line number Diff line change
1
+ public class AsExprTests : PrettyPrintTestCase {
2
+ public func testWithoutPunctuation( ) {
3
+ let input =
4
+ """
5
+ func foo() {
6
+ let a = b as Int
7
+ let c = d
8
+ as
9
+ Int
10
+ let reallyLongVariableName = x as ReallyLongTypeName
11
+ }
12
+ """
13
+
14
+ let expected =
15
+ """
16
+ func foo() {
17
+ let a = b as Int
18
+ let c = d as Int
19
+ let reallyLongVariableName =
20
+ x as ReallyLongTypeName
21
+ }
22
+
23
+ """
24
+
25
+ assertPrettyPrintEqual ( input: input, expected: expected, linelength: 40 )
26
+ }
27
+
28
+ public func testWithPunctuation( ) {
29
+ let input =
30
+ """
31
+ func foo() {
32
+ let a = b as? Int
33
+ let c = d
34
+ as!
35
+ Int
36
+ let reallyLongVariableName = x as? ReallyLongTypeName
37
+ }
38
+ """
39
+
40
+ let expected =
41
+ """
42
+ func foo() {
43
+ let a = b as? Int
44
+ let c = d as! Int
45
+ let reallyLongVariableName =
46
+ x as? ReallyLongTypeName
47
+ }
48
+
49
+ """
50
+
51
+ assertPrettyPrintEqual ( input: input, expected: expected, linelength: 40 )
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments