@@ -41,6 +41,7 @@ final class DeclarationTests: XCTestCase {
41
41
DiagnosticSpec ( locationMarker: " DIAG1 " , message: " Expected '' in function " ) ,
42
42
DiagnosticSpec ( locationMarker: " DIAG1 " , message: " Expected argument list in function declaration " ) ,
43
43
DiagnosticSpec ( locationMarker: " DIAG2 " , message: " Expected '=' in same type requirement " ) ,
44
+ DiagnosticSpec ( locationMarker: " DIAG2 " , message: " Expected right-hand type of same type requirement " ) ,
44
45
] )
45
46
}
46
47
@@ -77,12 +78,14 @@ final class DeclarationTests: XCTestCase {
77
78
AssertParse ( " class T where t#^DIAG^# " ,
78
79
diagnostics: [
79
80
DiagnosticSpec ( message: " Expected '=' in same type requirement " ) ,
81
+ DiagnosticSpec ( message: " Expected right-hand type of same type requirement " ) ,
80
82
DiagnosticSpec ( message: " Expected '{' to start class " ) ,
81
83
DiagnosticSpec ( message: " Expected '}' to end class " ) ,
82
84
] )
83
85
AssertParse ( " class B<where g#^DIAG^# " ,
84
86
diagnostics: [
85
87
DiagnosticSpec ( message: " Expected '=' in same type requirement " ) ,
88
+ DiagnosticSpec ( message: " Expected right-hand type of same type requirement " ) ,
86
89
DiagnosticSpec ( message: " Expected '>' to end generic parameter clause " ) ,
87
90
DiagnosticSpec ( message: " Expected '{' to start class " ) ,
88
91
DiagnosticSpec ( message: " Expected '}' to end class " ) ,
@@ -171,7 +174,8 @@ final class DeclarationTests: XCTestCase {
171
174
AssertParse (
172
175
" _ = foo/* */?.description#^DIAG^# " ,
173
176
diagnostics: [
174
- DiagnosticSpec ( message: " Expected ':' after '? ...' in ternary expression " )
177
+ DiagnosticSpec ( message: " Expected ':' after '? ...' in ternary expression " ) ,
178
+ DiagnosticSpec ( message: " Expected expression " ) ,
175
179
]
176
180
)
177
181
@@ -545,9 +549,12 @@ final class DeclarationTests: XCTestCase {
545
549
AssertParse (
546
550
"""
547
551
struct a {
548
- public
552
+ public#^DIAG^#
549
553
}
550
- """
554
+ """ ,
555
+ diagnostics: [
556
+ DiagnosticSpec ( message: " Expected declaration after 'public' in struct " )
557
+ ]
551
558
)
552
559
}
553
560
@@ -638,7 +645,12 @@ final class DeclarationTests: XCTestCase {
638
645
639
646
func testExtraneousRightBraceRecovery( ) {
640
647
AssertParse (
641
- " class ABC { let def = ghi(jkl: mno) } #^DIAG^#} " ,
648
+ """
649
+ class ABC {
650
+ let def = ghi(jkl: mno)
651
+ }
652
+ #^DIAG^#}
653
+ """ ,
642
654
diagnostics: [
643
655
DiagnosticSpec ( message: " Extraneous '}' at top level " )
644
656
]
@@ -653,8 +665,8 @@ final class DeclarationTests: XCTestCase {
653
665
}
654
666
""" ,
655
667
diagnostics: [
656
- // FIXME: This diagnostic should be more contextual
657
- DiagnosticSpec ( message: " Expected '->' in return clause " )
668
+ DiagnosticSpec ( message : " Expected '->' in subscript " ) ,
669
+ DiagnosticSpec ( message: " Expected return type in subscript " ) ,
658
670
]
659
671
)
660
672
}
@@ -694,16 +706,13 @@ final class DeclarationTests: XCTestCase {
694
706
func testExpressionMember( ) {
695
707
AssertParse (
696
708
"""
697
- struct S {
698
- #^DIAG ^#/ ###line 25 " line-directive.swift "
709
+ struct S {#^EXPECTED_DECL^#
710
+ #^UNEXPECTED_TEXT ^#/ ###line 25 " line-directive.swift "
699
711
}
700
712
""" ,
701
713
diagnostics: [
702
- DiagnosticSpec (
703
- message: """
704
- Unexpected text '/ ###line 25 " line-directive.swift " ' in struct
705
- """
706
- )
714
+ DiagnosticSpec ( locationMarker: " EXPECTED_DECL " , message: " Expected declaration after '{' in struct " ) ,
715
+ DiagnosticSpec ( locationMarker: " UNEXPECTED_TEXT " , message: #"Unexpected text '/ ###line 25 "line-directive.swift"' in struct"# )
707
716
]
708
717
)
709
718
}
@@ -889,12 +898,17 @@ final class DeclarationTests: XCTestCase {
889
898
func testMalforedStruct( ) {
890
899
AssertParse (
891
900
"""
892
- struct n#^OPENINGBRACES^##if@#^ENDIF^##^CLOSINGBRACES^#
901
+ struct n#^OPENING_BRACE^#
902
+ #if#^AFTER_POUND_IF^#
903
+ @#^END^#
893
904
""" ,
894
905
diagnostics: [
895
- DiagnosticSpec ( locationMarker: " OPENINGBRACES " , message: " Expected '{' to start struct " ) ,
896
- DiagnosticSpec ( locationMarker: " ENDIF " , message: " Expected '#endif' in conditional compilation block " ) ,
897
- DiagnosticSpec ( locationMarker: " CLOSINGBRACES " , message: " Expected '}' to end struct " )
906
+ DiagnosticSpec ( locationMarker: " OPENING_BRACE " , message: " Expected '{' to start struct " ) ,
907
+ DiagnosticSpec ( locationMarker: " AFTER_POUND_IF " , message: " Expected condition of conditional compilation clause " ) ,
908
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected declaration after '@' in conditional compilation clause " ) ,
909
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected name of attribute " ) ,
910
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected '#endif' in conditional compilation block " ) ,
911
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected '}' to end struct " )
898
912
]
899
913
)
900
914
}
@@ -996,7 +1010,8 @@ final class DeclarationTests: XCTestCase {
996
1010
diagnostics: [
997
1011
DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Unexpected text '}' before subscript " ) ,
998
1012
DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected argument list in function declaration " ) ,
999
- DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '->' in return clause " ) ,
1013
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '->' in subscript " ) ,
1014
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected return type in subscript " ) ,
1000
1015
] )
1001
1016
}
1002
1017
0 commit comments