File tree 2 files changed +14
-3
lines changed 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,7 @@ public enum SyntaxFactory {
199
199
public static func makeStringLiteralExpr( _ text: String ,
200
200
leadingTrivia: Trivia = [ ] ,
201
201
trailingTrivia: Trivia = [ ] ) -> StringLiteralExprSyntax {
202
- let string = makeStringSegment ( text,
203
- leadingTrivia: leadingTrivia,
204
- trailingTrivia: trailingTrivia)
202
+ let string = makeStringSegment ( text)
205
203
let segment = makeStringSegment ( content: string)
206
204
let segments = makeStringLiteralSegments ( [ segment] )
207
205
let openQuote = makeStringQuoteToken ( leadingTrivia: leadingTrivia)
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
24
24
( " testFunctionCallSyntaxBuilder " , testFunctionCallSyntaxBuilder) ,
25
25
( " testWithOptionalChild " , testWithOptionalChild) ,
26
26
( " testUnknownSyntax " , testUnknownSyntax) ,
27
+ ( " testMakeStringLiteralExpr " , testMakeStringLiteralExpr) ,
27
28
]
28
29
29
30
public func testGenerated( ) {
@@ -160,4 +161,16 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
160
161
XCTAssertNoThrow ( try SyntaxVerifier . verify ( expr) )
161
162
XCTAssertThrowsError ( try SyntaxVerifier . verify ( unknown) )
162
163
}
164
+
165
+ public func testMakeStringLiteralExpr( ) {
166
+ let expr = SyntaxFactory . makeStringLiteralExpr (
167
+ " Hello, world! " ,
168
+ leadingTrivia: . init( pieces: [ . lineComment( " // hello " ) , . newlines( 1 ) ] )
169
+ )
170
+ let expected = """
171
+ // hello
172
+ " Hello, world! "
173
+ """
174
+ XCTAssertEqual ( expr. description, expected)
175
+ }
163
176
}
You can’t perform that action at this time.
0 commit comments