File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
CodeGeneration/Sources/generate-swiftbasicformat
Sources/SwiftBasicFormat/generated
Tests/SwiftSyntaxBuilderTest Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ let basicFormatFile = SourceFile {
141
141
switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) {
142
142
case (.asKeyword, .exclamationMark),
143
143
(.asKeyword, .postfixQuestionMark),
144
+ (.initKeyword, .leftParen),
144
145
(.initKeyword, .postfixQuestionMark),
145
146
(.tryKeyword, .exclamationMark),
146
147
(.tryKeyword, .postfixQuestionMark):
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ open class BasicFormat: SyntaxRewriter {
140
140
switch ( token. tokenKind, token. nextToken ( viewMode: . sourceAccurate) ? . tokenKind) {
141
141
case ( . asKeyword, . exclamationMark) ,
142
142
( . asKeyword, . postfixQuestionMark) ,
143
+ ( . initKeyword, . leftParen) ,
143
144
( . initKeyword, . postfixQuestionMark) ,
144
145
( . tryKeyword, . exclamationMark) ,
145
146
( . tryKeyword, . postfixQuestionMark) :
Original file line number Diff line number Diff line change @@ -16,15 +16,27 @@ import SwiftSyntaxBuilder
16
16
17
17
final class InitializerDeclTests : XCTestCase {
18
18
func testInitializerDecl( ) {
19
+ let builder = InitializerDecl ( """
20
+ public init(errorCode: Int) {
21
+ self.code = errorCode
22
+ }
23
+ """ )
24
+
25
+ AssertBuildResult ( builder, """
26
+ public init(errorCode: Int) {
27
+ self.code = errorCode
28
+ }
29
+ """ )
30
+ }
31
+
32
+ func testFailableInitializerDecl( ) {
19
33
let builder = InitializerDecl ( """
20
34
public init?(errorCode: Int) {
21
35
guard errorCode > 0 else { return nil }
22
36
self.code = errorCode
23
37
}
24
38
""" )
25
39
26
- print ( builder. formatted ( ) . description)
27
-
28
40
AssertBuildResult ( builder, """
29
41
public init?(errorCode: Int) {
30
42
guard errorCode > 0 else {
You can’t perform that action at this time.
0 commit comments