@@ -30,28 +30,22 @@ final class TypeTests: ParserTestCase {
30
30
}
31
31
32
32
func testClosureParsing( ) {
33
- assertParse (
34
- " (a, b) -> c " ,
35
- { TypeSyntax . parse ( from: & $0) }
36
- )
33
+ assertParse ( " let a: (a, b) -> c " )
37
34
38
- assertParse (
39
- " @MainActor (a, b) async throws -> c " ,
40
- { TypeSyntax . parse ( from: & $0) }
41
- )
35
+ assertParse ( " let a: @MainActor (a, b) async throws -> c " )
42
36
43
37
assertParse ( " () -> ( \u{feff} ) " )
44
38
}
45
39
46
40
func testGenericTypeWithTrivia( ) {
47
- // N.B. Whitespace is significant here.
41
+ // Whitespace is significant here.
48
42
assertParse (
49
43
"""
44
+ let a:
50
45
Foo<Bar<
51
46
V, Baz<Quux>
52
47
>>
53
- """ ,
54
- { TypeSyntax . parse ( from: & $0) }
48
+ """
55
49
)
56
50
}
57
51
@@ -82,20 +76,17 @@ final class TypeTests: ParserTestCase {
82
76
"""
83
77
{ ()
84
78
throws -> Void in }
85
- """ ,
86
- { ExprSyntax . parse ( from: & $0) }
79
+ """
87
80
)
88
81
89
82
assertParse (
90
83
"""
91
84
{ [weak a, unowned(safe) self, b = 3] (a: Int, b: Int, _: Int) -> Int in }
92
- """ ,
93
- { ExprSyntax . parse ( from: & $0) }
85
+ """
94
86
)
95
87
96
88
assertParse (
97
89
" ℹ️{[1️⃣class]in2️⃣ " ,
98
- { ExprSyntax . parse ( from: & $0) } ,
99
90
diagnostics: [
100
91
DiagnosticSpec (
101
92
locationMarker: " 1️⃣ " ,
@@ -121,15 +112,13 @@ final class TypeTests: ParserTestCase {
121
112
122
113
assertParse (
123
114
" {[n1️⃣`]in} " ,
124
- { ExprSyntax . parse ( from: & $0) } ,
125
115
diagnostics: [
126
116
DiagnosticSpec ( message: " unexpected code '`' in closure capture clause " )
127
117
]
128
118
)
129
119
130
120
assertParse (
131
121
" {[weak1️⃣^]in} " ,
132
- { ExprSyntax . parse ( from: & $0) } ,
133
122
diagnostics: [
134
123
DiagnosticSpec ( message: " expected identifier in closure capture " , fixIts: [ " insert identifier " ] ) ,
135
124
DiagnosticSpec ( message: " unexpected code '^' in closure capture clause " ) ,
@@ -195,37 +184,34 @@ final class TypeTests: ParserTestCase {
195
184
196
185
func testLowercaseSelf( ) {
197
186
assertParse (
198
- " 1️⃣self2️⃣ " ,
199
- { TypeSyntax . parse ( from: & $0) } ,
187
+ " let a: 1️⃣self " ,
200
188
diagnostics: [
201
- DiagnosticSpec ( locationMarker : " 1️⃣ " , message : " unexpected 'self' keyword before type" ) ,
202
- DiagnosticSpec ( locationMarker : " 2️⃣ " , message: " expected type " , fixIts: [ " insert type " ] ) ,
189
+ DiagnosticSpec ( message : " expected type in type annotation " , fixIts : [ " insert type" ] ) ,
190
+ DiagnosticSpec ( message: " expected '=' in variable " , fixIts: [ " insert '=' " ] ) ,
203
191
] ,
204
- fixedSource: " <#type#>self "
192
+ fixedSource: " let a: <#type#> = self"
205
193
)
206
194
}
207
195
208
196
func testUppercaseSelf( ) {
209
197
assertParse (
210
- " Self " ,
211
- { TypeSyntax . parse ( from : & $0 ) } ,
212
- substructure : Syntax ( TokenSyntax . keyword ( . Self ) )
198
+ " let a: 1️⃣Self " ,
199
+ substructure : Syntax ( TokenSyntax . keyword ( . Self ) ) ,
200
+ substructureAfterMarker : " 1️⃣ "
213
201
)
214
202
}
215
203
216
204
func testNestedLowercaseSelf( ) {
217
205
assertParse (
218
- " Foo.1️⃣self " ,
219
- { TypeSyntax . parse ( from: & $0) } ,
206
+ " let a: Foo.1️⃣self " ,
220
207
substructure: Syntax ( TokenSyntax . keyword ( . `self`) ) ,
221
208
substructureAfterMarker: " 1️⃣ "
222
209
)
223
210
}
224
211
225
212
func testNestedUppercaseSelf( ) {
226
213
assertParse (
227
- " Foo.1️⃣Self " ,
228
- { TypeSyntax . parse ( from: & $0) } ,
214
+ " let a: Foo.1️⃣Self " ,
229
215
substructure: Syntax ( TokenSyntax . identifier ( " Self " ) ) ,
230
216
substructureAfterMarker: " 1️⃣ "
231
217
)
0 commit comments