Skip to content

Commit

Permalink
Provide evidence edits changes hlint diags
Browse files Browse the repository at this point in the history
  • Loading branch information
jneira committed Oct 28, 2020
1 parent ff0e4c7 commit 01f8fd8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/functional/FunctionalCodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ hlintTests = testGroup "hlint suggestions" [
contents <- skipManyTill publishDiagnosticsNotification $ getDocumentEdit doc
liftIO $ contents `elem` ["main = undefined\nfoo = id\n", "main = undefined\nfoo x = x\n"] @? "Command is applied"

, testCase "changing configuration enables or disables hints" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do
, testCase "changing configuration enables or disables hlint diagnostics" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do
let config = def { hlintOn = True }
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))

Expand All @@ -98,6 +98,31 @@ hlintTests = testGroup "hlint suggestions" [

liftIO $ Just "hlint" `notElem` map (^. L.source) diags' @? "There are no hlint diagnostics"

, testCase "changing document contents updates hlint diagnostics" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do
doc <- openDoc "ApplyRefact2.hs" "haskell"
diags <- waitForDiagnosticsSource "hlint"

liftIO $ length diags @?= 2 -- "Eta Reduce" and "Redundant Id"

let change = TextDocumentContentChangeEvent
(Just (Range (Position 1 8) (Position 1 12)))
Nothing "x"

changeDoc doc [change]

diags' <- waitForDiagnostics

liftIO $ (not $ Just "hlint" `elem` map (^. L.source) diags') @? "There are no hlint diagnostics"

let change' = TextDocumentContentChangeEvent
(Just (Range (Position 1 8) (Position 1 12)))
Nothing "id x"

changeDoc doc [change']

diags'' <- waitForDiagnosticsSource "hlint"

liftIO $ length diags'' @?= 2
]

renameTests :: TestTree
Expand Down

0 comments on commit 01f8fd8

Please sign in to comment.