Skip to content

Commit 899230d

Browse files
committed
Restore hlint test changing doc content
1 parent cffaa4f commit 899230d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/functional/FunctionalCodeAction.hs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@ hlintTests = testGroup "hlint suggestions" [
8383
contents <- skipManyTill anyMessage $ getDocumentEdit doc
8484
liftIO $ contents @?= "main = undefined\nfoo = id\n"
8585

86+
, testCase "changing configuration enables or disables hlint diagnostics" $ runHlintSession "" $ do
87+
let config = def { hlintOn = True }
88+
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))
89+
90+
doc <- openDoc "ApplyRefact2.hs" "haskell"
91+
testHlintDiagnostics doc
92+
93+
let config' = def { hlintOn = False }
94+
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config'))
95+
96+
diags' <- waitForDiagnosticsFrom doc
97+
98+
liftIO $ noHlintDiagnostics diags'
99+
100+
, testCase "changing document contents updates hlint diagnostics" $ runHlintSession "" $ do
101+
doc <- openDoc "ApplyRefact2.hs" "haskell"
102+
testHlintDiagnostics doc
103+
104+
let change = TextDocumentContentChangeEvent
105+
(Just (Range (Position 1 8) (Position 1 12)))
106+
Nothing "x"
107+
changeDoc doc [change]
108+
expectNoMoreDiagnostics 3 doc "hlint"
109+
110+
let change' = TextDocumentContentChangeEvent
111+
(Just (Range (Position 1 8) (Position 1 12)))
112+
Nothing "id x"
113+
changeDoc doc [change']
114+
testHlintDiagnostics doc
115+
86116
, knownBrokenForGhcVersions [GHC88, GHC86] "hlint doesn't take in account cpp flag as ghc -D argument" $
87117
testCase "hlint diagnostics works with CPP via ghc -XCPP argument (#554)" $ runHlintSession "cpp" $ do
88118
doc <- openDoc "ApplyRefact3.hs" "haskell"

0 commit comments

Comments
 (0)