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/translated/AvailabilityQueryUnavailabilityTests.swift
+29-9Lines changed: 29 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -481,29 +481,33 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase {
481
481
func testAvailabilityQueryUnavailability34a(){
482
482
assertParse(
483
483
"""
484
-
// Diagnose wrong spellings of unavailability
485
484
if #available(*) 1️⃣== false {
486
485
}
487
486
""",
488
487
diagnostics:[
489
488
DiagnosticSpec(message:"#available cannot be used as an expression, did you mean to use '#unavailable'?", fixIts:["replace '#available(*) == false' with '#unavailable(*)'"])
490
-
]
489
+
],
490
+
fixedSource:"""
491
+
if #unavailable(*) {
492
+
}
493
+
"""
491
494
)
492
495
}
493
496
494
497
func testAvailabilityQueryUnavailability34b(){
495
498
assertParse(
496
499
"""
497
-
// Diagnose wrong spellings of unavailability
498
-
if #available(*) 1️⃣== false && 2️⃣true {
500
+
if #available(*) 1️⃣== false 2️⃣&& true {
499
501
}
500
502
""",
501
503
diagnostics:[
502
-
DiagnosticSpec(locationMarker:"1️⃣", message:"unexpected code '== false &&' in 'if' statement"),
503
-
DiagnosticSpec(locationMarker:"2️⃣", message:"expected ',' in 'if' statement", fixIts:["insert ','"]),
504
-
// TODO: Old parser expected error on line 2: #available cannot be used as an expression, did you mean to use '#unavailable'?, Fix-It replacements: 4 - 14 = '#unavailable', 18 - 27 = ''
505
-
// TODO: Old parser expected error on line 2: expected ',' joining parts of a multi-clause condition, Fix-It replacements: 27 - 28 = ','
506
-
]
504
+
DiagnosticSpec(locationMarker:"1️⃣", message:"#available cannot be used as an expression, did you mean to use '#unavailable'?", fixIts:["replace '#available(*) == false' with '#unavailable(*)'"]),
505
+
DiagnosticSpec(locationMarker:"2️⃣", message:"expected ',' joining parts of a multi-clause condition", fixIts:["replace '&&' with ','"]),
506
+
],
507
+
fixedSource:"""
508
+
if #unavailable(*) , true {
509
+
}
510
+
"""
507
511
)
508
512
}
509
513
@@ -515,6 +519,22 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase {
515
519
""",
516
520
diagnostics:[
517
521
DiagnosticSpec(message:"availability condition cannot be used in an expression; did you mean '#unavailable'?", fixIts:["replace '!#available' with '#unavailable'"])
522
+
],
523
+
fixedSource:"""
524
+
if #unavailable(*) {
525
+
}
526
+
"""
527
+
)
528
+
}
529
+
530
+
func testAvailabilityQueryUnavailability34d(){
531
+
assertParse(
532
+
"""
533
+
if #available(*) 1️⃣== {
534
+
}
535
+
""",
536
+
diagnostics:[
537
+
DiagnosticSpec(locationMarker:"1️⃣", message:"unexpected code '==' in 'if' statement")
0 commit comments