@@ -91,6 +91,61 @@ final class DeclarationTests: ParserTestCase {
91
91
type: IdentifierTypeSyntax ( name: . identifier( " Int " ) )
92
92
)
93
93
)
94
+
95
+ assertParse (
96
+ """
97
+ class MyClass {
98
+ 1️⃣foo()
99
+ }
100
+ """ ,
101
+ diagnostics: [
102
+ DiagnosticSpec (
103
+ locationMarker: " 1️⃣ " ,
104
+ message: " expected 'func' in function " ,
105
+ fixIts: [ " insert 'func' " ]
106
+ )
107
+ ] ,
108
+ fixedSource: """
109
+ class MyClass {
110
+ func foo()
111
+ }
112
+ """
113
+ )
114
+
115
+ assertParse (
116
+ """
117
+ class MyClass {
118
+ 1️⃣foo<Int>2️⃣
119
+ }
120
+ """ ,
121
+ diagnostics: [
122
+ DiagnosticSpec (
123
+ locationMarker: " 1️⃣ " ,
124
+ message: " expected 'func' in function " ,
125
+ fixIts: [ " insert 'func' " ]
126
+ ) ,
127
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected parameter clause in function signature " , fixIts: [ " insert parameter clause " ] ) ,
128
+ ] ,
129
+ fixedSource: """
130
+ class MyClass {
131
+ func foo<Int>()
132
+ }
133
+ """
134
+ )
135
+
136
+ assertParse (
137
+ """
138
+ class MyClass {
139
+ 1️⃣foo
140
+ }
141
+ """ ,
142
+ diagnostics: [
143
+ DiagnosticSpec (
144
+ locationMarker: " 1️⃣ " ,
145
+ message: " unexpected code 'foo' in class "
146
+ )
147
+ ]
148
+ )
94
149
}
95
150
96
151
func testFuncAfterUnbalancedClosingBrace( ) {
@@ -1822,19 +1877,17 @@ final class DeclarationTests: ParserTestCase {
1822
1877
"""
1823
1878
struct Foo {
1824
1879
#1️⃣
1825
- 2️⃣myMacroName3️⃣
1880
+ 2️⃣myMacroName
1826
1881
}
1827
1882
""" ,
1828
1883
diagnostics: [
1829
1884
DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected identifier in macro expansion " , fixIts: [ " insert identifier " ] ) ,
1830
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected 'func' in function " , fixIts: [ " insert 'func' " ] ) ,
1831
- DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " expected parameter clause in function signature " , fixIts: [ " insert parameter clause " ] ) ,
1885
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " unexpected code 'myMacroName' in struct " ) ,
1832
1886
] ,
1833
1887
fixedSource: """
1834
1888
struct Foo {
1835
1889
#<#identifier#>
1836
- func
1837
- myMacroName()
1890
+ myMacroName
1838
1891
}
1839
1892
"""
1840
1893
)
@@ -2360,27 +2413,24 @@ final class DeclarationTests: ParserTestCase {
2360
2413
class A ℹ️{
2361
2414
1️⃣^
2362
2415
}
2363
- unowned 2️⃣B 3️⃣ {
2364
- }4️⃣
2416
+ unowned 2️⃣B {
2417
+ }
2365
2418
""" ,
2366
2419
diagnostics: [
2367
2420
DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " unexpected code before modifier " ) ,
2368
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected 'func' in function " , fixIts: [ " insert 'func' " ] ) ,
2369
- DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " expected parameter clause in function signature " , fixIts: [ " insert parameter clause " ] ) ,
2370
2421
DiagnosticSpec (
2371
- locationMarker: " 4️⃣ " ,
2372
- message: " expected '}' to end class " ,
2373
- notes: [ NoteSpec ( message: " to match this opening '{' " ) ] ,
2374
- fixIts: [ " insert '}' " ]
2422
+ locationMarker: " 2️⃣ " ,
2423
+ message: " expected declaration and '}' after 'unowned' modifier " ,
2424
+ fixIts: [ " insert declaration and '}' " ]
2375
2425
) ,
2376
2426
] ,
2377
2427
fixedSource:
2378
2428
"""
2379
2429
class A {
2380
2430
^
2381
2431
}
2382
- unowned func B() {
2383
- }
2432
+ unowned <#declaration#>
2433
+ }B {
2384
2434
}
2385
2435
"""
2386
2436
)
0 commit comments