Skip to content

Commit 01f8fd8

Browse files
committed
Provide evidence edits changes hlint diags
1 parent ff0e4c7 commit 01f8fd8

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Diff for: test/functional/FunctionalCodeAction.hs

+26-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ hlintTests = testGroup "hlint suggestions" [
8282
contents <- skipManyTill publishDiagnosticsNotification $ getDocumentEdit doc
8383
liftIO $ contents `elem` ["main = undefined\nfoo = id\n", "main = undefined\nfoo x = x\n"] @? "Command is applied"
8484

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

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

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

101+
, testCase "changing document contents updates hlint diagnostics" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do
102+
doc <- openDoc "ApplyRefact2.hs" "haskell"
103+
diags <- waitForDiagnosticsSource "hlint"
104+
105+
liftIO $ length diags @?= 2 -- "Eta Reduce" and "Redundant Id"
106+
107+
let change = TextDocumentContentChangeEvent
108+
(Just (Range (Position 1 8) (Position 1 12)))
109+
Nothing "x"
110+
111+
changeDoc doc [change]
112+
113+
diags' <- waitForDiagnostics
114+
115+
liftIO $ (not $ Just "hlint" `elem` map (^. L.source) diags') @? "There are no hlint diagnostics"
116+
117+
let change' = TextDocumentContentChangeEvent
118+
(Just (Range (Position 1 8) (Position 1 12)))
119+
Nothing "id x"
120+
121+
changeDoc doc [change']
122+
123+
diags'' <- waitForDiagnosticsSource "hlint"
124+
125+
liftIO $ length diags'' @?= 2
101126
]
102127

103128
renameTests :: TestTree

0 commit comments

Comments
 (0)