Skip to content

Commit 85be4f1

Browse files
committed
Simplify result type assertion.
1 parent 6c40203 commit 85be4f1

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

Tests/SwiftLexicalLookupTest/Assertions.swift

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ enum ResultExpectation {
6363
expectedNames
6464
}
6565
}
66-
67-
static func == (lhs: ResultExpectation, rhs: LookupResult) -> Bool {
68-
switch (lhs, rhs) {
69-
case (.fromScope, .fromScope):
70-
return true
71-
}
72-
}
7366
}
7467

7568
/// `methodUnderTest` is called with the token at every position marker in the keys of `expected`.
@@ -164,24 +157,17 @@ func assertLexicalNameLookup(
164157
let result = argument.lookup(for: useNilAsTheParameter ? nil : argument.text)
165158

166159
guard let expectedValues = references[marker] else {
167-
XCTFail("For marker \(marker), couldn't find expectation")
160+
XCTFail("For marker \(marker), couldn't find result expectation")
168161
return []
169162
}
170163

171164
for (actual, expected) in zip(result, expectedValues) {
172-
XCTAssert(
173-
expected == actual,
174-
"For marker \(marker), expected actual result \(actual) doesn't match expected \(expected)"
175-
)
176-
177-
switch actual {
178-
case .fromScope(let scope, withNames: _):
179-
if case .fromScope(let expectedType, expectedNames: _) = expected {
180-
XCTAssert(
181-
scope.syntaxNodeType == expectedType,
182-
"For marker \(marker), scope result type of \(scope.syntaxNodeType) doesn't match expected \(expectedType)"
183-
)
184-
}
165+
switch (actual, expected) {
166+
case (.fromScope(let scope, withNames: _), .fromScope(let expectedType, expectedNames: _)):
167+
XCTAssert(
168+
scope.syntaxNodeType == expectedType,
169+
"For marker \(marker), scope result type of \(scope.syntaxNodeType) doesn't match expected \(expectedType)"
170+
)
185171
}
186172
}
187173

0 commit comments

Comments
 (0)