@@ -621,82 +621,84 @@ final class RecoveryTests: XCTestCase {
621
621
func testRecovery46( ) {
622
622
assertParse (
623
623
"""
624
- switch {
625
- }1️⃣
624
+ switch 1️⃣ {
625
+ }
626
626
""" ,
627
627
diagnostics: [
628
- // TODO: Old parser expected error on line 1: expected expression in 'switch' statement
629
- // TODO: Old parser expected error on line 1: 'switch' statement body must have at least one 'case' or 'default' block
630
- DiagnosticSpec ( message: " expected '{}' in 'switch' statement " )
628
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected expression in 'switch' statement " )
631
629
]
632
630
)
633
631
}
634
632
635
633
func testRecovery47( ) {
636
634
assertParse (
637
635
"""
638
- switch
636
+ switch 1️⃣
639
637
{
640
- }1️⃣
638
+ }
641
639
""" ,
642
640
diagnostics: [
643
- // TODO: Old parser expected error on line 1: expected expression in 'switch' statement
644
- // TODO: Old parser expected error on line 1: 'switch' statement body must have at least one 'case' or 'default' block
645
- DiagnosticSpec ( message: " expected '{}' in 'switch' statement " )
641
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected expression in 'switch' statement " )
646
642
]
647
643
)
648
644
}
649
645
650
646
func testRecovery48( ) {
651
647
assertParse (
652
648
"""
653
- switch {
654
- 1️⃣case _: return
655
- }2️⃣
649
+ switch 1️⃣ {
650
+ 2️⃣case _: return
651
+ }
656
652
""" ,
657
653
diagnostics: [
658
- // TODO: Old parser expected error on line 1: expected expression in 'switch' statement
659
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " 'case' can only appear inside a 'switch' statement or 'enum' declaration " ) ,
660
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected '{}' in 'switch' statement " ) ,
654
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected expression in 'switch' statement " )
661
655
]
662
656
)
663
657
}
664
658
665
659
func testRecovery49( ) {
666
660
assertParse (
667
661
"""
668
- switch {
669
- 1️⃣case Int: return
670
- 2️⃣case _: return
671
- }3️⃣
662
+ switch 1️⃣ {
663
+ case Int: return
664
+ case _: return
665
+ }
672
666
""" ,
673
667
diagnostics: [
674
- // TODO: Old parser expected error on line 1: expected expression in 'switch' statement
668
+ DiagnosticSpec ( locationMarker : " 1️⃣ " , message : " expected expression in 'switch' statement " )
675
669
// TODO: Old parser expected error on line 2: 'is' keyword required to pattern match against type name, Fix-It replacements: 10 - 10 = 'is '
676
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " 'case' can only appear inside a 'switch' statement or 'enum' declaration " ) ,
677
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " 'case' can only appear inside a 'switch' statement or 'enum' declaration " ) ,
678
- DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " expected '{}' in 'switch' statement " ) ,
679
670
]
680
671
)
681
672
}
682
673
683
674
func testRecovery50( ) {
684
675
assertParse (
685
676
"""
686
- switch { 42 } {
687
- case _: return
677
+ switch 1️⃣{ 2️⃣42 } {
678
+ 3️⃣case _: return
688
679
}
689
- """
680
+ """ ,
681
+ diagnostics: [
682
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected expression in 'switch' statement " ) ,
683
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " all statements inside a switch must be covered by a 'case' or 'default' label " ) ,
684
+ DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " 'case' can only appear inside a 'switch' statement or 'enum' declaration " ) ,
685
+ ]
690
686
)
691
687
}
692
688
693
689
func testRecovery51( ) {
694
690
assertParse (
695
691
"""
696
- switch { 42 }() {
697
- case _: return
692
+ switch 1️⃣{ 2️⃣42 }()3️⃣ {
693
+ 4️⃣case _: return
698
694
}
699
- """
695
+ """ ,
696
+ diagnostics: [
697
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected expression in 'switch' statement " ) ,
698
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " all statements inside a switch must be covered by a 'case' or 'default' label " ) ,
699
+ DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " consecutive statements on a line must be separated by ';' " ) ,
700
+ DiagnosticSpec ( locationMarker: " 4️⃣ " , message: " 'case' can only appear inside a 'switch' statement or 'enum' declaration " ) ,
701
+ ]
700
702
)
701
703
}
702
704
0 commit comments