Skip to content

Commit f3f60d9

Browse files
committed
add test
1 parent 5d71e48 commit f3f60d9

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/functional/Completion.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ tests = testGroup "completions" [
8484
compls <- getCompletions doc (Position 5 7)
8585
liftIO $ assertBool "Expected completions" $ not $ null compls
8686

87+
, testGroup "recorddotsyntax"
88+
[ testCase "shows field selectors" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
89+
doc <- openDoc "RecordDotSyntax.hs" "haskell"
90+
91+
let te = TextEdit (Range (Position 25 0) (Position 25 5)) "z = x.a"
92+
_ <- applyEdit doc te
93+
94+
compls <- getCompletions doc (Position 25 6)
95+
item <- getCompletionByLabel "a" compls
96+
liftIO $ do
97+
item ^. label @?= "a"
98+
--item ^. detail @?= Just "Data.List" TODO
99+
--item ^. kind @?= Just CiModule
100+
liftIO $ length compls @?= 6
101+
]
102+
87103
-- See https://github.com/haskell/haskell-ide-engine/issues/903
88104
, testCase "strips compiler generated stuff from completions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
89105
doc <- openDoc "DupRecFields.hs" "haskell"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{-# LANGUAGE OverloadedRecordDot #-}
2+
{-# LANGUAGE DuplicateRecordFields #-}
3+
{-# LANGUAGE NoFieldSelectors #-}
4+
5+
module Test where
6+
7+
import qualified Data.Maybe as M
8+
9+
data MyRecord = MyRecord1
10+
{ a :: String
11+
, b :: Integer
12+
, c :: MyChild
13+
}
14+
| MyRecord2 { a2 :: String
15+
, b2 :: Integer
16+
, c2 :: MyChild
17+
} deriving (Eq, Show)
18+
19+
newtype MyChild = MyChild
20+
{ z :: String
21+
} deriving (Eq, Show)
22+
23+
x = MyRecord1 { a = "Hello", b = 12, c = MyChild { z = "there" } }
24+
25+
y = x.a ++ show x.b
26+
27+

0 commit comments

Comments
 (0)