Skip to content

Commit f8711c0

Browse files
authored
Merge pull request #975 from ahoppen/ahoppen/test-cleanup
Remove handled TODOs from DiagnoseDynamicReplacementTests and split tests in IfconfigExprTest
2 parents 6336f64 + 75492a3 commit f8711c0

File tree

2 files changed

+164
-32
lines changed

2 files changed

+164
-32
lines changed

Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ final class DiagnoseDynamicReplacementTests: XCTestCase {
2020
}
2121
""",
2222
diagnostics: [
23-
// TODO: Old parser expected error on line 1: expected '(' in '_dynamicReplacement' attribute
2423
DiagnosticSpec(message: "expected '(', attribute argument, and ')' in attribute"),
2524
]
2625
)
@@ -34,7 +33,6 @@ final class DiagnoseDynamicReplacementTests: XCTestCase {
3433
}
3534
""",
3635
diagnostics: [
37-
// TODO: Old parser expected error on line 1: expected 'for' in '_dynamicReplacement' attribute
3836
DiagnosticSpec(message: "expected argument for '@_dynamicReplacement' attribute"),
3937
DiagnosticSpec(message: "expected ')' to end attribute"),
4038
]
@@ -51,8 +49,7 @@ final class DiagnoseDynamicReplacementTests: XCTestCase {
5149
diagnostics: [
5250
DiagnosticSpec(message: "expected ')' to end attribute", notes: [
5351
NoteSpec(message: "to match this opening '('")
54-
]),
55-
// TODO: Old parser expected error on line 2: expected ')' after function name for @_dynamicReplacement
52+
])
5653
]
5754
)
5855
}

Tests/SwiftParserTest/translated/IfconfigExprTests.swift

Lines changed: 163 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ final class IfconfigExprTests: XCTestCase {
137137
#if CONDITION_1
138138
.methodOne()
139139
#elseif CONDITION_2
140-
1️⃣return
140+
1️⃣return
141141
#endif
142142
}
143143
""",
@@ -206,79 +206,214 @@ final class IfconfigExprTests: XCTestCase {
206206

207207
func testIfconfigExpr13() {
208208
AssertParse(
209-
#"""
210-
func canImportVersioned() {
209+
"""
211210
#if canImport(A, _version: 2)
212211
let a = 1
213212
#endif
213+
"""
214+
)
215+
}
216+
217+
func testIfconfigExpr14() {
218+
AssertParse(
219+
"""
214220
#if canImport(A, _version: 2.2)
215221
let a = 1
216222
#endif
223+
"""
224+
)
225+
}
226+
227+
func testIfconfigExpr15() {
228+
AssertParse(
229+
"""
217230
#if canImport(A, _version: 2.2.2)
218231
let a = 1
219232
#endif
233+
"""
234+
)
235+
}
236+
237+
func testIfconfigExpr16() {
238+
AssertParse(
239+
"""
220240
#if canImport(A, _version: 2.2.2.2)
221241
let a = 1
222242
#endif
223-
#if canImport(A, _version: 2.2.2.2.2)
243+
"""
244+
)
245+
}
246+
247+
func testIfconfigExpr17() {
248+
AssertParse(
249+
"""
250+
#if canImport(A, _version: 2.2.2.2.2)
224251
let a = 1
225252
#endif
253+
""",
254+
diagnostics: [
255+
// TODO: Old parser expected warning on line 1: trailing components of version '2.2.2.2' are ignored
256+
]
257+
)
258+
}
259+
260+
func testIfconfigExpr18() {
261+
AssertParse(
262+
"""
226263
#if canImport(A, _underlyingVersion: 4)
227264
let a = 1
228265
#endif
266+
"""
267+
)
268+
}
269+
270+
func testIfconfigExpr19() {
271+
AssertParse(
272+
"""
229273
#if canImport(A, _underlyingVersion: 2.200)
230274
let a = 1
231275
#endif
276+
"""
277+
)
278+
}
279+
280+
func testIfconfigExpr20() {
281+
AssertParse(
282+
"""
232283
#if canImport(A, _underlyingVersion: 2.200.1)
233284
let a = 1
234285
#endif
286+
"""
287+
)
288+
}
289+
290+
func testIfconfigExpr21() {
291+
AssertParse(
292+
"""
235293
#if canImport(A, _underlyingVersion: 2.200.1.3)
236294
let a = 1
237295
#endif
238-
#if canImport(A, unknown: 2.2)
296+
"""
297+
)
298+
}
299+
300+
func testIfconfigExpr22() {
301+
AssertParse(
302+
"""
303+
#if canImport(A, unknown: 2.2)
239304
let a = 1
240305
#endif
241-
#if canImport(A,1️⃣)
306+
""",
307+
diagnostics: [
308+
// TODO: Old parser expected error on line 1: 2nd parameter of canImport should be labeled as _version or _underlyingVersion
309+
]
310+
)
311+
}
312+
313+
func testIfconfigExpr23() {
314+
AssertParse(
315+
"""
316+
#if canImport(A,1️⃣)
242317
let a = 1
243318
#endif
244-
#if canImport(A, 2.2)
319+
""",
320+
diagnostics: [
321+
// TODO: Old parser expected error on line 1: unexpected ',' separator
322+
DiagnosticSpec(message: "expected value in function call")
323+
]
324+
)
325+
}
326+
327+
func testIfconfigExpr24() {
328+
AssertParse(
329+
"""
330+
#if canImport(A, 2.2)
245331
let a = 1
246332
#endif
247-
#if canImport(A, 2.2, 1.1)
333+
""",
334+
diagnostics: [
335+
// TODO: Old parser expected error on line 1: 2nd parameter of canImport should be labeled as _version or _underlyingVersion
336+
]
337+
)
338+
}
339+
340+
func testIfconfigExpr25() {
341+
AssertParse(
342+
"""
343+
#if canImport(A, 2.2, 1.1)
248344
let a = 1
249345
#endif
250-
#if canImport(A, _version:2️⃣)
346+
""",
347+
diagnostics: [
348+
// TODO: Old parser expected error on line 1: canImport can take only two parameters
349+
]
350+
)
351+
}
352+
353+
func testIfconfigExpr26() {
354+
AssertParse(
355+
"""
356+
#if canImport(A, _version:1️⃣)
251357
let a = 1
252358
#endif
253-
#if canImport(A, _version: "")
359+
""",
360+
diagnostics: [
361+
// TODO: Old parser expected error on line 1: expected expression in list of expressions
362+
DiagnosticSpec(message: "expected value in function call")
363+
]
364+
)
365+
}
366+
367+
func testIfconfigExpr27() {
368+
AssertParse(
369+
#"""
370+
#if canImport(A, _version: "")
254371
let a = 1
255372
#endif
256-
#if canImport(A, _version: >=2.2)
373+
"""#,
374+
diagnostics: [
375+
// TODO: Old parser expected error on line 1: _version argument cannot be empty
376+
]
377+
)
378+
}
379+
380+
func testIfconfigExpr28() {
381+
AssertParse(
382+
"""
383+
#if canImport(A, _version: >=2.2)
257384
let a = 1
258385
#endif
259-
#if canImport(A, _version: 3️⃣20A301)
386+
""",
387+
diagnostics: [
388+
// TODO: Old parser expected error on line 1: cannot parse module version '>=2.2'
389+
]
390+
)
391+
}
392+
393+
func testIfconfigExpr29() {
394+
AssertParse(
395+
"""
396+
#if canImport(A, _version: 1️⃣20A301)
260397
let a = 1
261398
#endif
262-
#if canImport(A, _version: "20A301")
399+
""",
400+
diagnostics: [
401+
// TODO: Old parser expected error on line 1: 'A' is not a valid digit in integer literal
402+
DiagnosticSpec(message: "expected value in function call"),
403+
DiagnosticSpec(message: "unexpected code '20A301' in function call"),
404+
]
405+
)
406+
}
407+
408+
func testIfconfigExpr30() {
409+
AssertParse(
410+
#"""
411+
#if canImport(A, _version: "20A301")
263412
let a = 1
264413
#endif
265-
}
266414
"""#,
267415
diagnostics: [
268-
// TODO: Old parser expected warning on line 14: trailing components of version '2.2.2.2' are ignored
269-
// TODO: Old parser expected error on line 29: 2nd parameter of canImport should be labeled as _version or _underlyingVersion
270-
// TODO: Old parser expected error on line 32: unexpected ',' separator
271-
DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in function call"),
272-
// TODO: Old parser expected error on line 35: 2nd parameter of canImport should be labeled as _version or _underlyingVersion
273-
// TODO: Old parser expected error on line 38: canImport can take only two parameters
274-
// TODO: Old parser expected error on line 41: expected expression in list of expressions
275-
DiagnosticSpec(locationMarker: "2️⃣", message: "expected value in function call"),
276-
// TODO: Old parser expected error on line 44: _version argument cannot be empty
277-
// TODO: Old parser expected error on line 47: cannot parse module version '>=2.2'
278-
// TODO: Old parser expected error on line 50: 'A' is not a valid digit in integer literal
279-
DiagnosticSpec(locationMarker: "3️⃣", message: "expected value in function call"),
280-
DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code '20A301' in function call"),
281-
// TODO: Old parser expected error on line 53: cannot parse module version '20A301'
416+
// TODO: Old parser expected error on line 1: cannot parse module version '20A301'
282417
]
283418
)
284419
}

0 commit comments

Comments
 (0)