@@ -621,82 +621,84 @@ final class RecoveryTests: XCTestCase {
621621 func testRecovery46( ) {
622622 assertParse (
623623 """
624- switch {
625- }1️⃣
624+ switch 1️⃣ {
625+ }
626626 """ ,
627627 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 " )
631629 ]
632630 )
633631 }
634632
635633 func testRecovery47( ) {
636634 assertParse (
637635 """
638- switch
636+ switch 1️⃣
639637 {
640- }1️⃣
638+ }
641639 """ ,
642640 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 " )
646642 ]
647643 )
648644 }
649645
650646 func testRecovery48( ) {
651647 assertParse (
652648 """
653- switch {
654- 1️⃣case _: return
655- }2️⃣
649+ switch 1️⃣ {
650+ 2️⃣case _: return
651+ }
656652 """ ,
657653 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 " )
661655 ]
662656 )
663657 }
664658
665659 func testRecovery49( ) {
666660 assertParse (
667661 """
668- switch {
669- 1️⃣case Int: return
670- 2️⃣case _: return
671- }3️⃣
662+ switch 1️⃣ {
663+ case Int: return
664+ case _: return
665+ }
672666 """ ,
673667 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 " )
675669 // 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 " ) ,
679670 ]
680671 )
681672 }
682673
683674 func testRecovery50( ) {
684675 assertParse (
685676 """
686- switch { 42 } {
687- case _: return
677+ switch 1️⃣{ 2️⃣42 } {
678+ 3️⃣case _: return
688679 }
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+ ]
690686 )
691687 }
692688
693689 func testRecovery51( ) {
694690 assertParse (
695691 """
696- switch { 42 }() {
697- case _: return
692+ switch 1️⃣{ 2️⃣42 }()3️⃣ {
693+ 4️⃣case _: return
698694 }
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+ ]
700702 )
701703 }
702704
0 commit comments