From 23fb3ba5cd1ec6e7a08528452c84f804be16df38 Mon Sep 17 00:00:00 2001 From: Alex Naspo Date: Thu, 16 Sep 2021 07:26:35 -0400 Subject: [PATCH] added tests for qualified completions --- ghcide/test/exe/Main.hs | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 109a5cbb5b..4a7c8423a0 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -4055,7 +4055,8 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do completionTests :: TestTree completionTests = testGroup "completion" - [ testGroup "non local" nonLocalCompletionTests + [ + testGroup "non local" nonLocalCompletionTests , testGroup "topLevel" topLevelCompletionTests , testGroup "local" localCompletionTests , testGroup "package" packageCompletionTests @@ -4589,7 +4590,41 @@ projectCompletionTests = <- compls , _label == "anidentifier" ] - liftIO $ compls' @?= ["Defined in 'A"] + liftIO $ compls' @?= ["Defined in 'A"], + testSession' "auto complete functions from qualified imports without alias" $ \dir-> do + liftIO $ writeFile (dir "hie.yaml") + "cradle: {direct: {arguments: [\"-Wmissing-signatures\", \"A\", \"B\"]}}" + _ <- createDoc "A.hs" "haskell" $ T.unlines + [ "module A (anidentifier) where", + "anidentifier = ()" + ] + _ <- waitForDiagnostics + doc <- createDoc "B.hs" "haskell" $ T.unlines + [ "module B where", + "import qualified A", + "A." + ] + compls <- getCompletions doc (Position 2 2) + let item = head compls + liftIO $ do + item ^. L.label @?= "anidentifier", + testSession' "auto complete functions from qualified imports with alias" $ \dir-> do + liftIO $ writeFile (dir "hie.yaml") + "cradle: {direct: {arguments: [\"-Wmissing-signatures\", \"A\", \"B\"]}}" + _ <- createDoc "A.hs" "haskell" $ T.unlines + [ "module A (anidentifier) where", + "anidentifier = ()" + ] + _ <- waitForDiagnostics + doc <- createDoc "B.hs" "haskell" $ T.unlines + [ "module B where", + "import qualified A as alias", + "alias." + ] + compls <- getCompletions doc (Position 2 6) + let item = head compls + liftIO $ do + item ^. L.label @?= "anidentifier" ] highlightTests :: TestTree