Skip to content

Commit

Permalink
test: Add regression tests for #2403
Browse files Browse the repository at this point in the history
  • Loading branch information
guibou committed Jan 10, 2022
1 parent aa5379d commit ea73091
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4527,6 +4527,15 @@ localCompletionTests = [
,("abcdefgh", CiFunction, "abcdefgh", True, False, Nothing)
,("abcdefghi", CiFunction, "abcdefghi", True, False, Nothing)
],
completionTest
"type family"
["{-# LANGUAGE DataKinds, TypeFamilies #-}"
,"type family Bar a"
,"a :: Ba"
]
(Position 2 7)
[("Bar", CiStruct, "Bar", True, False, Nothing)
],
completionTest
"class method"
[
Expand Down
11 changes: 11 additions & 0 deletions test/functional/Completion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ tests = testGroup "completions" [
item ^. detail @?= Just "Data.Maybe"
item ^. kind @?= Just CiModule

, testCase "completes type family" $ runSession (hlsCommand <> " --test") fullCaps "test/testdata/completion" $ do
doc <- openDoc "CompletionTypeFamily.hs" "haskell"

compls <- getCompletions doc (Position 9 16)
let item = head $ filter ((== "Bar") . (^. label)) compls
liftIO $ do
item ^. label @?= "Bar"
item ^. kind @?= Just CiStruct
item ^. detail @?= Just ":: Bar"
item ^. insertTextFormat @?= Just Snippet
item ^. insertText @?= Just "Bar"
, testCase "completes qualified imports" $ runSession (hlsCommand <> " --test") fullCaps "test/testdata/completion" $ do
doc <- openDoc "Completion.hs" "haskell"

Expand Down
11 changes: 11 additions & 0 deletions test/testdata/completion/CompletionTypeFamily.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Based on #2403
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}

module MyLib where

type family Bar a

class Foo a where
foo :: a -> Ba
foo = undefined

0 comments on commit ea73091

Please sign in to comment.