@@ -137,7 +137,7 @@ final class IfconfigExprTests: XCTestCase {
137
137
#if CONDITION_1
138
138
.methodOne()
139
139
#elseif CONDITION_2
140
- 1️⃣return
140
+ 1️⃣return
141
141
#endif
142
142
}
143
143
""" ,
@@ -206,79 +206,214 @@ final class IfconfigExprTests: XCTestCase {
206
206
207
207
func testIfconfigExpr13( ) {
208
208
AssertParse (
209
- #"""
210
- func canImportVersioned() {
209
+ """
211
210
#if canImport(A, _version: 2)
212
211
let a = 1
213
212
#endif
213
+ """
214
+ )
215
+ }
216
+
217
+ func testIfconfigExpr14( ) {
218
+ AssertParse (
219
+ """
214
220
#if canImport(A, _version: 2.2)
215
221
let a = 1
216
222
#endif
223
+ """
224
+ )
225
+ }
226
+
227
+ func testIfconfigExpr15( ) {
228
+ AssertParse (
229
+ """
217
230
#if canImport(A, _version: 2.2.2)
218
231
let a = 1
219
232
#endif
233
+ """
234
+ )
235
+ }
236
+
237
+ func testIfconfigExpr16( ) {
238
+ AssertParse (
239
+ """
220
240
#if canImport(A, _version: 2.2.2.2)
221
241
let a = 1
222
242
#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)
224
251
let a = 1
225
252
#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
+ """
226
263
#if canImport(A, _underlyingVersion: 4)
227
264
let a = 1
228
265
#endif
266
+ """
267
+ )
268
+ }
269
+
270
+ func testIfconfigExpr19( ) {
271
+ AssertParse (
272
+ """
229
273
#if canImport(A, _underlyingVersion: 2.200)
230
274
let a = 1
231
275
#endif
276
+ """
277
+ )
278
+ }
279
+
280
+ func testIfconfigExpr20( ) {
281
+ AssertParse (
282
+ """
232
283
#if canImport(A, _underlyingVersion: 2.200.1)
233
284
let a = 1
234
285
#endif
286
+ """
287
+ )
288
+ }
289
+
290
+ func testIfconfigExpr21( ) {
291
+ AssertParse (
292
+ """
235
293
#if canImport(A, _underlyingVersion: 2.200.1.3)
236
294
let a = 1
237
295
#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)
239
304
let a = 1
240
305
#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️⃣)
242
317
let a = 1
243
318
#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)
245
331
let a = 1
246
332
#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)
248
344
let a = 1
249
345
#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️⃣)
251
357
let a = 1
252
358
#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: "")
254
371
let a = 1
255
372
#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)
257
384
let a = 1
258
385
#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)
260
397
let a = 1
261
398
#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")
263
412
let a = 1
264
413
#endif
265
- }
266
414
"""# ,
267
415
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'
282
417
]
283
418
)
284
419
}
0 commit comments