Skip to content

Commit 66b2614

Browse files
committed
Added test data and test for ensuring Core-generated variables are not included in hover info.
1 parent 56c7bba commit 66b2614

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ghcide/test/data/hover/GotoHover.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ hole = _
6464

6565
hole2 :: a -> Maybe a
6666
hole2 = _
67+
68+
-- A comment above a type defnition with a deriving clause
69+
data Example = Example
70+
deriving (Eq)

ghcide/test/exe/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ findDefinitionAndHoverTests = let
10261026
ExpectRange expectedRange -> checkHoverRange expectedRange rangeInHover msg
10271027
ExpectHoverRange expectedRange -> checkHoverRange expectedRange rangeInHover msg
10281028
ExpectHoverText snippets -> liftIO $ traverse_ (`assertFoundIn` msg) snippets
1029+
ExpectHoverExcludeText snippets -> liftIO $ traverse_ (`assertNotFoundIn` msg) snippets
10291030
ExpectHoverTextRegex re -> liftIO $ assertBool ("Regex not found in " <> T.unpack msg) (msg =~ re :: Bool)
10301031
ExpectNoHover -> liftIO $ assertFailure $ "Expected no hover but got " <> show hover
10311032
_ -> pure () -- all other expectations not relevant to hover
@@ -1054,6 +1055,11 @@ findDefinitionAndHoverTests = let
10541055
(T.unpack $ "failed to find: `" <> part <> "` in hover message:\n" <> whole)
10551056
(part `T.isInfixOf` whole)
10561057

1058+
assertNotFoundIn :: T.Text -> T.Text -> Assertion
1059+
assertNotFoundIn part whole = assertBool
1060+
(T.unpack $ "found unexpected: `" <> part <> "` in hover message:\n" <> whole)
1061+
(not . T.isInfixOf part $ whole)
1062+
10571063
sourceFilePath = T.unpack sourceFileName
10581064
sourceFileName = "GotoHover.hs"
10591065

@@ -1130,6 +1136,7 @@ findDefinitionAndHoverTests = let
11301136
imported = Position 56 13 ; importedSig = getDocUri "Foo.hs" >>= \foo -> return [ExpectHoverText ["foo", "Foo", "Haddock"], mkL foo 5 0 5 3]
11311137
reexported = Position 55 14 ; reexportedSig = getDocUri "Bar.hs" >>= \bar -> return [ExpectHoverText ["Bar", "Bar", "Haddock"], mkL bar 3 (if ghcVersion >= GHC94 then 5 else 0) 3 (if ghcVersion >= GHC94 then 8 else 14)]
11321138
thLocL57 = Position 59 10 ; thLoc = [ExpectHoverText ["Identity"]]
1139+
cmtL68 = Position 67 0 ; lackOfdEq = [ExpectHoverExcludeText ["$dEq"]]
11331140
in
11341141
mkFindTests
11351142
-- def hover look expect
@@ -1173,6 +1180,7 @@ findDefinitionAndHoverTests = let
11731180
, test no broken chrL36 litC "literal Char in hover info #1016"
11741181
, test no broken txtL8 litT "literal Text in hover info #1016"
11751182
, test no broken lstL43 litL "literal List in hover info #1016"
1183+
, test yes yes cmtL68 lackOfdEq "no Core symbols #3280"
11761184
, if ghcVersion >= GHC90 then
11771185
test no yes docL41 constr "type constraint in hover info #1012"
11781186
else
@@ -2354,6 +2362,7 @@ data Expect
23542362
-- | ExpectDefRange Range -- Only gotoDef should report this range
23552363
| ExpectHoverRange Range -- Only hover should report this range
23562364
| ExpectHoverText [T.Text] -- the hover message must contain these snippets
2365+
| ExpectHoverExcludeText [T.Text] -- the hover message must _not_ contain these snippets
23572366
| ExpectHoverTextRegex T.Text -- the hover message must match this pattern
23582367
| ExpectExternFail -- definition lookup in other file expected to fail
23592368
| ExpectNoDefinitions

0 commit comments

Comments
 (0)