Skip to content

Commit 1e912c3

Browse files
committed
fix reference field test
1 parent 0a479aa commit 1e912c3

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

ghcide-test/data/references/Fields.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{-# LANGUAGE RecordWildCards #-}
2+
module Fields where
3+
4+
data Foo = MkFoo
5+
{
6+
barr :: String,
7+
bazz :: String
8+
}
9+
10+
fooUse0 :: Foo -> String
11+
fooUse0 MkFoo{barr} = "5"
12+
13+
fooUse1 :: Foo -> String
14+
fooUse1 MkFoo{..} = "6"
15+
16+
fooUse2 :: String -> String -> Foo
17+
fooUse2 bar baz =
18+
MkFoo{..}

ghcide-test/data/references/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main where
22

33
import References
4-
4+
import Fields
55
main :: IO ()
66
main = return ()
77

@@ -12,3 +12,6 @@ b = a + 1
1212

1313
acc :: Account
1414
acc = Savings
15+
16+
fooUse3 :: String -> String -> Foo
17+
fooUse3 bar baz = MkFoo{barr = bar, bazz = baz}
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{-# LANGUAGE RecordWildCards #-}
21
module References where
2+
33
import OtherModule
44

55
foo = bar
@@ -23,19 +23,3 @@ bobHasChecking = case bobsAccount of
2323
x = symbolDefinedInOtherModule
2424

2525
y = symbolDefinedInOtherOtherModule
26-
27-
data Foo = MkFoo
28-
{
29-
barr :: Int,
30-
bazz :: String
31-
}
32-
33-
fooUse0 :: Foo -> Int
34-
fooUse0 MkFoo{barr} = 5
35-
36-
fooUse1 :: Foo -> Int
37-
fooUse1 MkFoo{..} = 6
38-
39-
fooUse2 :: Int -> String -> Foo
40-
fooUse2 bar baz =
41-
MkFoo{..}

ghcide-test/data/references/hie.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cradle: {direct: {arguments: ["Main","OtherModule","OtherOtherModule","References"]}}
1+
cradle: {direct: {arguments: ["Main","OtherModule","OtherOtherModule","References", "Fields"]}}

ghcide-test/exe/ReferenceTests.hs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,23 @@ tests = testGroup "references"
155155
, ("References.hs", 12, 5)
156156
, ("References.hs", 16, 0)
157157
]
158-
, referenceTest "references record fields"
159-
("References.hs", 29, 5)
158+
]
159+
, testGroup "references to record fields"
160+
[ referenceTest "references record fields in the same file"
161+
("Fields.hs", 5, 4)
162+
YesIncludeDeclaration
163+
[ ("Fields.hs", 5, 4)
164+
, ("Fields.hs", 10, 14)
165+
, ("Fields.hs", 13, 14)
166+
]
167+
168+
, referenceTest "references record fields cross modules"
169+
("Main.hs", 16, 24)
160170
YesIncludeDeclaration
161-
[ ("References.hs", 29, 4)
162-
, ("References.hs", 36, 14)
171+
[ ("Fields.hs", 5, 4)
172+
, ("Fields.hs", 10, 14)
173+
, ("Fields.hs", 13, 14)
174+
, ("Main.hs", 16, 24)
163175
]
164176
]
165177
]

0 commit comments

Comments
 (0)