@@ -101,34 +101,45 @@ PositionTests.test("Recursion") {
101
101
} )
102
102
}
103
103
104
- PositionTests . test ( " Trivias " ) {
105
- expectDoesNotThrow ( {
106
- let leading = Trivia ( pieces: [
104
+ func createSourceFile( _ count: Int ) -> SourceFileSyntax {
105
+ let leading = Trivia ( pieces: [
107
106
. newlines( 1 ) ,
108
107
. backticks( 1 ) ,
109
108
. docLineComment( " /// some comment " )
110
109
] )
111
- let trailing = Trivia . docLineComment ( " /// This is comment \n " )
112
- let idx = 5
113
- let items : [ CodeBlockItemSyntax ] =
114
- [ CodeBlockItemSyntax ] ( repeating : CodeBlockItemSyntax {
115
- $0. useItem ( ReturnStmtSyntax {
116
- $0 . useReturnKeyword (
117
- SyntaxFactory . makeReturnKeyword (
118
- leadingTrivia : leading ,
119
- trailingTrivia : trailing ) )
120
- } ) } , count : idx + 1 )
121
- let root = SyntaxFactory . makeSourceFile (
122
- statements : SyntaxFactory . makeCodeBlockItemList ( items ) ,
123
- eofToken : SyntaxFactory . makeToken ( . eof , presence : . present ) )
110
+ let trailing = Trivia . docLineComment ( " /// This is comment \n " )
111
+ let items : [ CodeBlockItemSyntax ] =
112
+ [ CodeBlockItemSyntax] ( repeating : CodeBlockItemSyntax {
113
+ $0 . useItem ( ReturnStmtSyntax {
114
+ $0. useReturnKeyword (
115
+ SyntaxFactory . makeReturnKeyword (
116
+ leadingTrivia : leading ,
117
+ trailingTrivia : trailing ) )
118
+ } ) } , count : count )
119
+ return SyntaxFactory . makeSourceFile (
120
+ statements : SyntaxFactory . makeCodeBlockItemList ( items ) ,
121
+ eofToken : SyntaxFactory . makeToken ( . eof , presence : . present ) )
122
+ }
124
123
124
+ PositionTests . test ( " Trivias " ) {
125
+ expectDoesNotThrow ( {
126
+ let idx = 5
127
+ let root = createSourceFile ( idx + 1 )
125
128
expectEqual ( root. leadingTrivia!. count, 3 )
126
129
expectEqual ( root. trailingTrivia!. count, 0 )
127
130
let state = root. statements [ idx]
128
131
expectEqual ( state. leadingTrivia!. count, 3 )
129
132
expectEqual ( state. trailingTrivia!. count, 1 )
130
133
expectEqual ( state. leadingTrivia!. byteSize + state. trailingTrivia!. byteSize
131
134
+ state. byteSizeAfterTrimmingTrivia, state. byteSize)
135
+ expectFalse ( root. statements. isImplicit)
136
+ } )
137
+ }
138
+
139
+ PositionTests . test ( " Implicit " ) {
140
+ expectDoesNotThrow ( {
141
+ let root = createSourceFile ( 0 )
142
+ expectTrue ( root. statements. isImplicit)
132
143
} )
133
144
}
134
145
0 commit comments