You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tests/SwiftParserTest/DeclarationTests.swift
+37-37Lines changed: 37 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ final class DeclarationTests: XCTestCase {
55
55
diagnostics:[
56
56
DiagnosticSpec(locationMarker:"1️⃣", message:"keyword 'where' cannot be used as an identifier here", fixIts:["if this name is unavoidable, use backticks to escape it"]),
57
57
DiagnosticSpec(locationMarker:"2️⃣", message:"expected '(' to start parameter clause", fixIts:["insert '('"]),
58
-
DiagnosticSpec(locationMarker:"3️⃣", message:"expected ':' and type in parameter"),
58
+
DiagnosticSpec(locationMarker:"3️⃣", message:"expected ':' and type in parameter", fixIts:["insert ':' and type"]),
59
59
DiagnosticSpec(locationMarker:"3️⃣", message:"expected ')' to end parameter clause", fixIts:["insert ')'"]),
60
60
],
61
61
fixedSource:"""
@@ -124,15 +124,15 @@ final class DeclarationTests: XCTestCase {
124
124
"class T where t1️⃣",
125
125
diagnostics:[
126
126
DiagnosticSpec(message:"expected ':' or '==' to indicate a conformance or same-type requirement"),
127
-
DiagnosticSpec(message:"expected member block in class"),
127
+
DiagnosticSpec(message:"expected member block in class", fixIts:["insert member block"]),
128
128
]
129
129
)
130
130
assertParse(
131
131
"class B<where g1️⃣",
132
132
diagnostics:[
133
133
DiagnosticSpec(message:"expected ':' or '==' to indicate a conformance or same-type requirement"),
134
-
DiagnosticSpec(message:"expected '>' to end generic parameter clause"),
135
-
DiagnosticSpec(message:"expected member block in class"),
134
+
DiagnosticSpec(message:"expected '>' to end generic parameter clause", fixIts:["insert '>'"]),
135
+
DiagnosticSpec(message:"expected member block in class", fixIts:["insert member block"]),
136
136
]
137
137
)
138
138
}
@@ -188,8 +188,8 @@ final class DeclarationTests: XCTestCase {
188
188
"protocol P{1️⃣{}case2️⃣",
189
189
diagnostics:[
190
190
DiagnosticSpec(locationMarker:"1️⃣", message:"unexpected code '{}' before enum case"),
191
-
DiagnosticSpec(locationMarker:"2️⃣", message:"expected identifier in enum case"),
192
-
DiagnosticSpec(locationMarker:"2️⃣", message:"expected '}' to end protocol"),
191
+
DiagnosticSpec(locationMarker:"2️⃣", message:"expected identifier in enum case", fixIts:["insert identifier"]),
192
+
DiagnosticSpec(locationMarker:"2️⃣", message:"expected '}' to end protocol", fixIts:["insert '}'"]),
193
193
]
194
194
)
195
195
}
@@ -220,7 +220,7 @@ final class DeclarationTests: XCTestCase {
220
220
assertParse(
221
221
"_ = foo/* */?.description1️⃣",
222
222
diagnostics:[
223
-
DiagnosticSpec(message:"expected ':' and expression after '? ...' in ternary expression")
223
+
DiagnosticSpec(message:"expected ':' and expression after '? ...' in ternary expression", fixIts:["insert ':' and expression"])
224
224
]
225
225
)
226
226
@@ -288,8 +288,8 @@ final class DeclarationTests: XCTestCase {
288
288
internal(set) var defaultProp = 0
289
289
""",
290
290
diagnostics:[
291
-
DiagnosticSpec(locationMarker:"1️⃣", message:"consecutive statements on a line must be separated by ';'"),
292
-
DiagnosticSpec(locationMarker:"2️⃣", message:"consecutive statements on a line must be separated by ';'"),
291
+
DiagnosticSpec(locationMarker:"1️⃣", message:"consecutive statements on a line must be separated by ';'", fixIts:["insert ';'"]),
292
+
DiagnosticSpec(locationMarker:"2️⃣", message:"consecutive statements on a line must be separated by ';'", fixIts:["insert ';'"]),
293
293
]
294
294
)
295
295
@@ -298,7 +298,7 @@ final class DeclarationTests: XCTestCase {
298
298
private(1️⃣get) var a = 0
299
299
""",
300
300
diagnostics:[
301
-
DiagnosticSpec(message:"expected 'set' in modifier"),
301
+
DiagnosticSpec(message:"expected 'set' in modifier", fixIts:["insert 'set'"]),
302
302
DiagnosticSpec(message:"unexpected code 'get' in modifier"),
303
303
]
304
304
)
@@ -310,7 +310,7 @@ final class DeclarationTests: XCTestCase {
310
310
) var a = 0
311
311
""",
312
312
diagnostics:[
313
-
DiagnosticSpec(message:"expected 'set)' to end modifier"),
313
+
DiagnosticSpec(message:"expected 'set)' to end modifier", fixIts:["insert 'set)'"]),
314
314
// FIXME: It should print `+` as detail of text.
315
315
DiagnosticSpec(message:"unexpected code in variable"),
316
316
]
@@ -348,7 +348,7 @@ final class DeclarationTests: XCTestCase {
348
348
private(1️⃣var a = 0
349
349
""",
350
350
diagnostics:[
351
-
DiagnosticSpec(message:"expected 'set)' to end modifier")
351
+
DiagnosticSpec(message:"expected 'set)' to end modifier", fixIts:["insert 'set)'"])
352
352
]
353
353
)
354
354
@@ -367,7 +367,7 @@ final class DeclarationTests: XCTestCase {
367
367
private(1️⃣get, didSet var a = 0
368
368
""",
369
369
diagnostics:[
370
-
DiagnosticSpec(message:"expected 'set)' to end modifier"),
370
+
DiagnosticSpec(message:"expected 'set)' to end modifier", fixIts:["insert 'set)'"]),
371
371
DiagnosticSpec(message:"unexpected code 'get, didSet' in variable"),
372
372
]
373
373
)
@@ -601,7 +601,7 @@ final class DeclarationTests: XCTestCase {
601
601
}
602
602
""",
603
603
diagnostics:[
604
-
DiagnosticSpec(message:"expected declaration after 'public' modifier")
604
+
DiagnosticSpec(message:"expected declaration after 'public' modifier", fixIts:["insert declaration"])
605
605
]
606
606
)
607
607
}
@@ -610,7 +610,7 @@ final class DeclarationTests: XCTestCase {
610
610
assertParse(
611
611
"func test(first second 1️⃣Int)",
612
612
diagnostics:[
613
-
DiagnosticSpec(message:"expected ':' in parameter")
613
+
DiagnosticSpec(message:"expected ':' in parameter", fixIts:["insert ':'"])
614
614
]
615
615
)
616
616
}
@@ -628,7 +628,7 @@ final class DeclarationTests: XCTestCase {
628
628
assertParse(
629
629
"func test(first second: Int1️⃣",
630
630
diagnostics:[
631
-
DiagnosticSpec(message:"expected ')' to end parameter clause")
631
+
DiagnosticSpec(message:"expected ')' to end parameter clause", fixIts:["insert ')'"])
632
632
]
633
633
)
634
634
}
@@ -637,7 +637,7 @@ final class DeclarationTests: XCTestCase {
637
637
assertParse(
638
638
"func test 1️⃣first second: Int)",
639
639
diagnostics:[
640
-
DiagnosticSpec(message:"expected '(' to start parameter clause")
640
+
DiagnosticSpec(message:"expected '(' to start parameter clause", fixIts:["insert '('"])
641
641
]
642
642
)
643
643
}
@@ -665,7 +665,7 @@ final class DeclarationTests: XCTestCase {
665
665
)
666
666
),
667
667
diagnostics:[
668
-
DiagnosticSpec(message:"expected parameter clause in function signature")
668
+
DiagnosticSpec(message:"expected parameter clause in function signature", fixIts:["insert parameter clause"])
669
669
]
670
670
)
671
671
}
@@ -702,7 +702,7 @@ final class DeclarationTests: XCTestCase {
702
702
}
703
703
""",
704
704
diagnostics:[
705
-
DiagnosticSpec(message:"expected '->' and return type in subscript")
705
+
DiagnosticSpec(message:"expected '->' and return type in subscript", fixIts:["insert '->' and return type"])
706
706
]
707
707
)
708
708
}
@@ -747,9 +747,9 @@ final class DeclarationTests: XCTestCase {
747
747
4️⃣}
748
748
""",
749
749
diagnostics:[
750
-
DiagnosticSpec(locationMarker:"1️⃣", message:"expected '}' to end struct"),
750
+
DiagnosticSpec(locationMarker:"1️⃣", message:"expected '}' to end struct", fixIts:["insert '}'"]),
751
751
DiagnosticSpec(locationMarker:"2️⃣", message:"bare slash regex literal may not start with space"),
752
-
DiagnosticSpec(locationMarker:"3️⃣", message:"expected '/' to end regex literal"),
752
+
DiagnosticSpec(locationMarker:"3️⃣", message:"expected '/' to end regex literal", fixIts:["insert '/\'"]),
753
753
DiagnosticSpec(locationMarker:"4️⃣", message:"extraneous brace at top level"),
754
754
]
755
755
)
@@ -788,10 +788,10 @@ final class DeclarationTests: XCTestCase {
0 commit comments