Skip to content

Commit f8bd345

Browse files
CodaFijpsim
authored andcommitted
Store the Line and Column in DiagnosticSpec
Make XCTest point at the actual expectation that failed, not the call to AssertParse
1 parent d9c7ec4 commit f8bd345

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Tests/SwiftParserTest/Assertions.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,25 @@ struct DiagnosticSpec {
6464
/// If not `nil`, assert that the diagnostic contains fix-its with these messages.
6565
/// Use the `fixedSource` parameter on `AssertParse` to check that applying the Fix-It yields the expected result.
6666
let fixIts: [String]?
67+
let file: StaticString
68+
let line: UInt
6769

68-
init(locationMarker: String = "DIAG", id: MessageID? = nil, message: String?, highlight: String? = nil, fixIts: [String]? = nil) {
70+
init(
71+
locationMarker: String = "DIAG",
72+
id: MessageID? = nil,
73+
message: String?,
74+
highlight: String? = nil,
75+
fixIts: [String]? = nil,
76+
file: StaticString = #file,
77+
line: UInt = #line
78+
) {
6979
self.locationMarker = locationMarker
7080
self.id = id
7181
self.message = message
7282
self.highlight = highlight
7383
self.fixIts = fixIts
84+
self.file = file
85+
self.line = line
7486
}
7587
}
7688

@@ -232,7 +244,7 @@ func AssertParse<Node: RawSyntaxNodeProtocol>(
232244
""", file: file, line: line)
233245
}
234246
for (diag, expectedDiag) in zip(diags, expectedDiagnostics) {
235-
AssertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag, file: file, line: line)
247+
AssertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag, file: expectedDiag.file, line: expectedDiag.line)
236248
}
237249

238250
// Applying Fix-Its

0 commit comments

Comments
 (0)