Skip to content

Commit 2e5780f

Browse files
committed
Add test for attached trivia
1 parent e34ae93 commit 2e5780f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/SwiftSyntaxBuilderTest/TriviaTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,22 @@ final class TriviaTests: XCTestCase {
3232
XCTAssertEqual(y, x + .space)
3333
XCTAssertEqual(y, [.newlines(1), .spaces(1)])
3434
}
35+
36+
func testAttachedTrivia() {
37+
let testCases: [UInt: (VariableDecl, String)] = [
38+
#line: (
39+
VariableDecl(.let, name: "x", type: "Int").withLeadingTrivia(.space),
40+
" let x: Int"
41+
),
42+
#line: (
43+
VariableDecl(.let, name: "x", type: "Int").withTrailingTrivia(.space),
44+
"let x: Int "
45+
),
46+
]
47+
for (line, testCase) in testCases {
48+
let (decl, expected) = testCase
49+
let syntax = decl.buildSyntax(format: Format())
50+
XCTAssertEqual(syntax.description, expected, line: line)
51+
}
52+
}
3553
}

0 commit comments

Comments
 (0)