Skip to content

Commit cd496cb

Browse files
Fix test for code completion of qualified name.
Stop messing around the editing the file and reloading it. We are trying to test code completion, not editing files, and the extra complexity is making it harder to maintain the test.
1 parent 33dee2e commit cd496cb

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

test/functional/Completion.hs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -366,28 +366,11 @@ contextTests = testGroup "contexts" [
366366
, testCase "completes qualified type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
367367
doc <- openDoc "Context.hs" "haskell"
368368
_ <- waitForDiagnosticsFrom doc
369-
let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc."
370-
_ <- applyEdit doc te
371-
-- The module doesn't parse right now. So we are using stale data. HLS
372-
-- can give us completions for "Conc." but it can't tell that we are in
373-
-- a context where we expect a type.
374369
compls <- getCompletions doc (Position 2 26)
375370
liftIO $ do
376-
-- forkOn is an inappropriate completion in a type context.
377-
compls `shouldContainCompl` "forkOn"
371+
compls `shouldNotContainCompl` "forkOn"
378372
compls `shouldContainCompl` "MVar"
379373
compls `shouldContainCompl` "Chan"
380-
let te' = TextEdit (Range (Position 2 26) (Position 2 26)) "MVar"
381-
_ <- applyEdit doc te'
382-
-- The module can now be parsed. Wait until it has been.
383-
_ <- waitForDiagnosticsFrom doc
384-
-- HLS can see that we are expecting a type.
385-
compls' <- getCompletions doc (Position 2 26)
386-
liftIO $ do
387-
-- forkOn is gone.
388-
compls' `shouldNotContainCompl` "forkOn"
389-
compls' `shouldContainCompl` "MVar"
390-
compls' `shouldContainCompl` "Chan"
391374
]
392375

393376
shouldContainCompl :: [CompletionItem] -> T.Text -> Assertion

test/testdata/completion/Context.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Context where
22
import Control.Concurrent as Conc
3-
foo :: Int -> Int
3+
foo :: Int -> Int -> Conc.MVar
44
foo x = abs $ id 42

0 commit comments

Comments
 (0)