@@ -63,10 +63,13 @@ import System.FilePath (equalFilePath)
6363import System.Time.Extra
6464import Test.Tasty.HUnit
6565
66+ expectedDiagnosticWithNothing :: ExpectedDiagnostic -> ExpectedDiagnosticWithTag
67+ expectedDiagnosticWithNothing (ds, c, t, code) = (ds, c, t, code, Nothing )
68+
6669requireDiagnosticM
6770 :: (Foldable f , Show (f Diagnostic ), HasCallStack )
6871 => f Diagnostic
69- -> ( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text , Maybe DiagnosticTag )
72+ -> ExpectedDiagnosticWithTag
7073 -> Assertion
7174requireDiagnosticM actuals expected = case requireDiagnostic actuals expected of
7275 Nothing -> pure ()
@@ -114,15 +117,15 @@ flushMessages = do
114117--
115118-- Rather than trying to assert the absence of diagnostics, introduce an
116119-- expected diagnostic (e.g. a redundant import) and assert the singleton diagnostic.
117- expectDiagnostics :: HasCallStack => [(FilePath , [( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text ) ])] -> Session ()
120+ expectDiagnostics :: HasCallStack => [(FilePath , [ExpectedDiagnostic ])] -> Session ()
118121expectDiagnostics
119122 = expectDiagnosticsWithTags
120- . map (second (map ( \ (ds, c, t, code) -> (ds, c, t, code, Nothing )) ))
123+ . map (second (map expectedDiagnosticWithNothing ))
121124
122125unwrapDiagnostic :: TServerMessage Method_TextDocumentPublishDiagnostics -> (Uri , [Diagnostic ])
123126unwrapDiagnostic diagsNot = (diagsNot^. L. params . L. uri, diagsNot^. L. params . L. diagnostics)
124127
125- expectDiagnosticsWithTags :: HasCallStack => [(String , [( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text , Maybe DiagnosticTag ) ])] -> Session ()
128+ expectDiagnosticsWithTags :: HasCallStack => [(String , [ExpectedDiagnosticWithTag ])] -> Session ()
126129expectDiagnosticsWithTags expected = do
127130 let toSessionPath = getDocUri >=> liftIO . canonicalizeUri >=> pure . toNormalizedUri
128131 next = unwrapDiagnostic <$> skipManyTill anyMessage diagnostic
@@ -132,7 +135,7 @@ expectDiagnosticsWithTags expected = do
132135expectDiagnosticsWithTags' ::
133136 (HasCallStack , MonadIO m ) =>
134137 m (Uri , [Diagnostic ]) ->
135- Map. Map NormalizedUri [( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text , Maybe DiagnosticTag ) ] ->
138+ Map. Map NormalizedUri [ExpectedDiagnosticWithTag ] ->
136139 m ()
137140expectDiagnosticsWithTags' next m | null m = do
138141 (_,actual) <- next
@@ -170,14 +173,14 @@ expectDiagnosticsWithTags' next expected = go expected
170173 <> show actual
171174 go $ Map. delete canonUri m
172175
173- expectCurrentDiagnostics :: HasCallStack => TextDocumentIdentifier -> [( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text ) ] -> Session ()
176+ expectCurrentDiagnostics :: HasCallStack => TextDocumentIdentifier -> [ExpectedDiagnostic ] -> Session ()
174177expectCurrentDiagnostics doc expected = do
175178 diags <- getCurrentDiagnostics doc
176179 checkDiagnosticsForDoc doc expected diags
177180
178- checkDiagnosticsForDoc :: HasCallStack => TextDocumentIdentifier -> [( DiagnosticSeverity , Cursor , T. Text , Maybe T. Text ) ] -> [Diagnostic ] -> Session ()
181+ checkDiagnosticsForDoc :: HasCallStack => TextDocumentIdentifier -> [ExpectedDiagnostic ] -> [Diagnostic ] -> Session ()
179182checkDiagnosticsForDoc TextDocumentIdentifier {_uri} expected obtained = do
180- let expected' = Map. singleton nuri (map ( \ (ds, c, t, code) -> (ds, c, t, code, Nothing )) expected)
183+ let expected' = Map. singleton nuri (map expectedDiagnosticWithNothing expected)
181184 nuri = toNormalizedUri _uri
182185 expectDiagnosticsWithTags' (return (_uri, obtained)) expected'
183186
0 commit comments