Skip to content

Commit ea73091

Browse files
committed
test: Add regression tests for #2403
1 parent aa5379d commit ea73091

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ghcide/test/exe/Main.hs

+9
Original file line numberDiff line numberDiff line change
@@ -4527,6 +4527,15 @@ localCompletionTests = [
45274527
,("abcdefgh", CiFunction, "abcdefgh", True, False, Nothing)
45284528
,("abcdefghi", CiFunction, "abcdefghi", True, False, Nothing)
45294529
],
4530+
completionTest
4531+
"type family"
4532+
["{-# LANGUAGE DataKinds, TypeFamilies #-}"
4533+
,"type family Bar a"
4534+
,"a :: Ba"
4535+
]
4536+
(Position 2 7)
4537+
[("Bar", CiStruct, "Bar", True, False, Nothing)
4538+
],
45304539
completionTest
45314540
"class method"
45324541
[

test/functional/Completion.hs

+11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ tests = testGroup "completions" [
6161
item ^. detail @?= Just "Data.Maybe"
6262
item ^. kind @?= Just CiModule
6363

64+
, testCase "completes type family" $ runSession (hlsCommand <> " --test") fullCaps "test/testdata/completion" $ do
65+
doc <- openDoc "CompletionTypeFamily.hs" "haskell"
66+
67+
compls <- getCompletions doc (Position 9 16)
68+
let item = head $ filter ((== "Bar") . (^. label)) compls
69+
liftIO $ do
70+
item ^. label @?= "Bar"
71+
item ^. kind @?= Just CiStruct
72+
item ^. detail @?= Just ":: Bar"
73+
item ^. insertTextFormat @?= Just Snippet
74+
item ^. insertText @?= Just "Bar"
6475
, testCase "completes qualified imports" $ runSession (hlsCommand <> " --test") fullCaps "test/testdata/completion" $ do
6576
doc <- openDoc "Completion.hs" "haskell"
6677

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Based on #2403
2+
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE TypeFamilies #-}
4+
5+
module MyLib where
6+
7+
type family Bar a
8+
9+
class Foo a where
10+
foo :: a -> Ba
11+
foo = undefined

0 commit comments

Comments
 (0)