Skip to content

Commit d947153

Browse files
alexnaspopepeiborra
authored andcommitted
added tests for qualified completions
1 parent 982c50c commit d947153

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

ghcide/test/exe/Main.hs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4107,7 +4107,8 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
41074107
completionTests :: TestTree
41084108
completionTests
41094109
= testGroup "completion"
4110-
[ testGroup "non local" nonLocalCompletionTests
4110+
[
4111+
testGroup "non local" nonLocalCompletionTests
41114112
, testGroup "topLevel" topLevelCompletionTests
41124113
, testGroup "local" localCompletionTests
41134114
, testGroup "package" packageCompletionTests
@@ -4659,7 +4660,41 @@ projectCompletionTests =
46594660
compls <- getCompletions doc (Position 1 13)
46604661
let item = head $ filter ((== "ALocalModule") . (^. Lens.label)) compls
46614662
liftIO $ do
4662-
item ^. Lens.label @?= "ALocalModule"
4663+
item ^. Lens.label @?= "ALocalModule",
4664+
testSession' "auto complete functions from qualified imports without alias" $ \dir-> do
4665+
liftIO $ writeFile (dir </> "hie.yaml")
4666+
"cradle: {direct: {arguments: [\"-Wmissing-signatures\", \"A\", \"B\"]}}"
4667+
_ <- createDoc "A.hs" "haskell" $ T.unlines
4668+
[ "module A (anidentifier) where",
4669+
"anidentifier = ()"
4670+
]
4671+
_ <- waitForDiagnostics
4672+
doc <- createDoc "B.hs" "haskell" $ T.unlines
4673+
[ "module B where",
4674+
"import qualified A",
4675+
"A."
4676+
]
4677+
compls <- getCompletions doc (Position 2 2)
4678+
let item = head compls
4679+
liftIO $ do
4680+
item ^. L.label @?= "anidentifier",
4681+
testSession' "auto complete functions from qualified imports with alias" $ \dir-> do
4682+
liftIO $ writeFile (dir </> "hie.yaml")
4683+
"cradle: {direct: {arguments: [\"-Wmissing-signatures\", \"A\", \"B\"]}}"
4684+
_ <- createDoc "A.hs" "haskell" $ T.unlines
4685+
[ "module A (anidentifier) where",
4686+
"anidentifier = ()"
4687+
]
4688+
_ <- waitForDiagnostics
4689+
doc <- createDoc "B.hs" "haskell" $ T.unlines
4690+
[ "module B where",
4691+
"import qualified A as Alias",
4692+
"foo = Alias."
4693+
]
4694+
compls <- getCompletions doc (Position 2 12)
4695+
let item = head compls
4696+
liftIO $ do
4697+
item ^. L.label @?= "anidentifier"
46634698
]
46644699

46654700
highlightTests :: TestTree

0 commit comments

Comments
 (0)