@@ -210,7 +210,7 @@ knownIssueFor solution = go . \case
210
210
go True = case solution of
211
211
Broken -> expectFailBecause
212
212
Ignore -> ignoreTestBecause
213
- go False = \ _ -> id
213
+ go False = const id
214
214
215
215
data Expect
216
216
= ExpectRange Range -- Both gotoDef and hover should report this range
@@ -278,21 +278,22 @@ pattern R x y x' y' = Range (Position x y) (Position x' y')
278
278
checkDefs :: Definition |? ([DefinitionLink ] |? Null ) -> Session [Expect ] -> Session ()
279
279
checkDefs (defToLocation -> defs) mkExpectations = traverse_ check =<< mkExpectations where
280
280
check (ExpectRange expectedRange) = do
281
- assertNDefinitionsFound 1 defs
282
- assertRangeCorrect ( head defs) expectedRange
281
+ def <- assertOneDefinitionFound defs
282
+ assertRangeCorrect def expectedRange
283
283
check (ExpectLocation expectedLocation) = do
284
- assertNDefinitionsFound 1 defs
284
+ def <- assertOneDefinitionFound defs
285
285
liftIO $ do
286
- canonActualLoc <- canonicalizeLocation ( head defs)
286
+ canonActualLoc <- canonicalizeLocation def
287
287
canonExpectedLoc <- canonicalizeLocation expectedLocation
288
288
canonActualLoc @?= canonExpectedLoc
289
289
check ExpectNoDefinitions = do
290
- assertNDefinitionsFound 0 defs
290
+ liftIO $ assertBool " Expecting no definitions " $ null defs
291
291
check ExpectExternFail = liftIO $ assertFailure " Expecting to fail to find in external file"
292
292
check _ = pure () -- all other expectations not relevant to getDefinition
293
293
294
- assertNDefinitionsFound :: Int -> [a ] -> Session ()
295
- assertNDefinitionsFound n defs = liftIO $ assertEqual " number of definitions" n (length defs)
294
+ assertOneDefinitionFound :: [Location ] -> Session Location
295
+ assertOneDefinitionFound [def] = pure def
296
+ assertOneDefinitionFound _ = liftIO $ assertFailure " Expecting exactly one definition"
296
297
297
298
assertRangeCorrect Location {_range = foundRange} expectedRange =
298
299
liftIO $ expectedRange @=? foundRange
0 commit comments