@@ -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,13 +78,15 @@ 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<#^DIAG_1^#where g#^DIAG_2^# " ,
84
86
diagnostics: [
85
87
DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Expected '>' to end generic parameter clause " ) ,
86
88
DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '=' in same type requirement " ) ,
89
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected right-hand type of same type requirement " ) ,
87
90
DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '{' to start class " ) ,
88
91
DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected '}' to end class " ) ,
89
92
] )
@@ -147,7 +150,8 @@ final class DeclarationTests: XCTestCase {
147
150
AssertParse (
148
151
" _ = foo/* */?.description#^DIAG^# " ,
149
152
diagnostics: [
150
- DiagnosticSpec ( message: " Expected ':' after '? ...' in ternary expression " )
153
+ DiagnosticSpec ( message: " Expected ':' after '? ...' in ternary expression " ) ,
154
+ DiagnosticSpec ( message: " Expected expression " ) ,
151
155
]
152
156
)
153
157
@@ -396,9 +400,12 @@ final class DeclarationTests: XCTestCase {
396
400
AssertParse (
397
401
"""
398
402
struct a {
399
- public
403
+ public#^DIAG^#
400
404
}
401
- """
405
+ """ ,
406
+ diagnostics: [
407
+ DiagnosticSpec ( message: " Expected declaration after 'public' in struct " )
408
+ ]
402
409
)
403
410
}
404
411
@@ -489,7 +496,12 @@ final class DeclarationTests: XCTestCase {
489
496
490
497
func testExtraneousRightBraceRecovery( ) {
491
498
AssertParse (
492
- " class ABC { let def = ghi(jkl: mno) } #^DIAG^#} " ,
499
+ """
500
+ class ABC {
501
+ let def = ghi(jkl: mno)
502
+ }
503
+ #^DIAG^#}
504
+ """ ,
493
505
diagnostics: [
494
506
DiagnosticSpec ( message: " Extraneous '}' at top level " )
495
507
]
@@ -504,8 +516,8 @@ final class DeclarationTests: XCTestCase {
504
516
}
505
517
""" ,
506
518
diagnostics: [
507
- // FIXME: This diagnostic should be more contextual
508
- DiagnosticSpec ( message: " Expected '->' in return clause " )
519
+ DiagnosticSpec ( message : " Expected '->' in subscript " ) ,
520
+ DiagnosticSpec ( message: " Expected return type in subscript " ) ,
509
521
]
510
522
)
511
523
}
@@ -552,16 +564,13 @@ final class DeclarationTests: XCTestCase {
552
564
func testExpressionMember( ) {
553
565
AssertParse (
554
566
"""
555
- struct S {
556
- #^DIAG ^#/ ###line 25 " line-directive.swift "
567
+ struct S {#^EXPECTED_DECL^#
568
+ #^UNEXPECTED_TEXT ^#/ ###line 25 " line-directive.swift "
557
569
}
558
570
""" ,
559
571
diagnostics: [
560
- DiagnosticSpec (
561
- message: """
562
- Unexpected text '/ ###line 25 " line-directive.swift " ' found in struct
563
- """
564
- )
572
+ DiagnosticSpec ( locationMarker: " EXPECTED_DECL " , message: " Expected declaration after '{' in struct " ) ,
573
+ DiagnosticSpec ( locationMarker: " UNEXPECTED_TEXT " , message: #"Unexpected text '/ ###line 25 "line-directive.swift"' found in struct"# )
565
574
]
566
575
)
567
576
}
@@ -735,12 +744,17 @@ final class DeclarationTests: XCTestCase {
735
744
func testMalforedStruct( ) {
736
745
AssertParse (
737
746
"""
738
- struct n#^OPENINGBRACES^##if@#^ENDIF^##^CLOSINGBRACES^#
747
+ struct n#^OPENING_BRACE^#
748
+ #if#^AFTER_POUND_IF^#
749
+ @#^END^#
739
750
""" ,
740
751
diagnostics: [
741
- DiagnosticSpec ( locationMarker: " OPENINGBRACES " , message: " Expected '{' to start struct " ) ,
742
- DiagnosticSpec ( locationMarker: " ENDIF " , message: " Expected '#endif' in conditional compilation block " ) ,
743
- DiagnosticSpec ( locationMarker: " CLOSINGBRACES " , message: " Expected '}' to end struct " )
752
+ DiagnosticSpec ( locationMarker: " OPENING_BRACE " , message: " Expected '{' to start struct " ) ,
753
+ DiagnosticSpec ( locationMarker: " AFTER_POUND_IF " , message: " Expected condition of conditional compilation clause " ) ,
754
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected declaration after '@' in conditional compilation clause " ) ,
755
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected name of attribute " ) ,
756
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected '#endif' in conditional compilation block " ) ,
757
+ DiagnosticSpec ( locationMarker: " END " , message: " Expected '}' to end struct " )
744
758
]
745
759
)
746
760
}
0 commit comments