@@ -782,6 +782,55 @@ final class DeclarationTests: XCTestCase {
782
782
}
783
783
"""## )
784
784
}
785
+
786
+ func testLeadingUnexpectedTokens( ) {
787
+ AssertParse ( " #^DIAG_1^#}class C#^DIAG_2^# " ,
788
+ diagnostics: [
789
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in class " ) ,
790
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start class " ) ,
791
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end class " ) ,
792
+ ] )
793
+ AssertParse ( " #^DIAG_1^#}enum C#^DIAG_2^# " ,
794
+ diagnostics: [
795
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in enum " ) ,
796
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start enum " ) ,
797
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end enum " ) ,
798
+ ] )
799
+ AssertParse ( " #^DIAG_1^#}protocol C#^DIAG_2^# " ,
800
+ diagnostics: [
801
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in protocol " ) ,
802
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start protocol " ) ,
803
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end protocol " ) ,
804
+ ] )
805
+ AssertParse ( " #^DIAG_1^#}actor C#^DIAG_2^# " ,
806
+ diagnostics: [
807
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in actor " ) ,
808
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start actor " ) ,
809
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end actor " ) ,
810
+ ] )
811
+ AssertParse ( " #^DIAG_1^#}struct C#^DIAG_2^# " ,
812
+ diagnostics: [
813
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in struct " ) ,
814
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start struct " ) ,
815
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end struct " ) ,
816
+ ] )
817
+ AssertParse ( " #^DIAG_1^#}func C#^DIAG_2^# " ,
818
+ diagnostics: [
819
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in function " ) ,
820
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected argument list in function declaration " ) ,
821
+ ] )
822
+ AssertParse ( " #^DIAG_1^#}init#^DIAG_2^# " ,
823
+ diagnostics: [
824
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in initializer " ) ,
825
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected argument list in function declaration " ) ,
826
+ ] )
827
+ AssertParse ( " #^DIAG_1^#}subscript#^DIAG_2^# " ,
828
+ diagnostics: [
829
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' found in subscript " ) ,
830
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected argument list in function declaration " ) ,
831
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '->' in return clause " ) ,
832
+ ] )
833
+ }
785
834
}
786
835
787
836
extension Parser . DeclAttributes {
0 commit comments