Skip to content

Commit 70914a8

Browse files
committed
Use XCTFail over XCTAssertNil for substructure matching
There's no reason to print the nil assertion message when matching tree substructures - we just want the diff message itself.
1 parent 8e42331 commit 70914a8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ public struct SubtreeMatcher {
112112
/// `init(markedText:)` has the same structure as `expected`.
113113
public func assertSameStructure(afterMarker: String? = nil, _ expected: Syntax, includeTrivia: Bool = false,
114114
file: StaticString = #filePath, line: UInt = #line) throws {
115-
let diff = try findFirstDifference(afterMarker: afterMarker, baseline: expected, includeTrivia: includeTrivia)
116-
XCTAssertNil(diff, diff!.debugDescription, file: file, line: line)
115+
if let diff = try findFirstDifference(afterMarker: afterMarker, baseline: expected, includeTrivia: includeTrivia) {
116+
XCTFail(diff.debugDescription, file: file, line: line)
117+
}
117118
}
118119
}
119120

0 commit comments

Comments
 (0)