Skip to content

Commit ece5bb9

Browse files
committed
Added test data and test for ensuring Core-generated variables are not included in hover info.
1 parent 78e0380 commit ece5bb9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ghcide/test/data/hover/GotoHover.hs

+4
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

+9
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ findDefinitionAndHoverTests = let
10011001
ExpectRange expectedRange -> checkHoverRange expectedRange rangeInHover msg
10021002
ExpectHoverRange expectedRange -> checkHoverRange expectedRange rangeInHover msg
10031003
ExpectHoverText snippets -> liftIO $ traverse_ (`assertFoundIn` msg) snippets
1004+
ExpectHoverExcludeText snippets -> liftIO $ traverse_ (`assertNotFoundIn` msg) snippets
10041005
ExpectHoverTextRegex re -> liftIO $ assertBool ("Regex not found in " <> T.unpack msg) (msg =~ re :: Bool)
10051006
ExpectNoHover -> liftIO $ assertFailure $ "Expected no hover but got " <> show hover
10061007
_ -> pure () -- all other expectations not relevant to hover
@@ -1029,6 +1030,11 @@ findDefinitionAndHoverTests = let
10291030
(T.unpack $ "failed to find: `" <> part <> "` in hover message:\n" <> whole)
10301031
(part `T.isInfixOf` whole)
10311032

1033+
assertNotFoundIn :: T.Text -> T.Text -> Assertion
1034+
assertNotFoundIn part whole = assertBool
1035+
(T.unpack $ "found unexpected: `" <> part <> "` in hover message:\n" <> whole)
1036+
(not . T.isInfixOf part $ whole)
1037+
10321038
sourceFilePath = T.unpack sourceFileName
10331039
sourceFileName = "GotoHover.hs"
10341040

@@ -1105,6 +1111,7 @@ findDefinitionAndHoverTests = let
11051111
imported = Position 56 13 ; importedSig = getDocUri "Foo.hs" >>= \foo -> return [ExpectHoverText ["foo", "Foo", "Haddock"], mkL foo 5 0 5 3]
11061112
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)]
11071113
thLocL57 = Position 59 10 ; thLoc = [ExpectHoverText ["Identity"]]
1114+
cmtL68 = Position 67 0 ; lackOfdEq = [ExpectHoverExcludeText ["$dEq"]]
11081115
in
11091116
mkFindTests
11101117
-- def hover look expect
@@ -1148,6 +1155,7 @@ findDefinitionAndHoverTests = let
11481155
, test no broken chrL36 litC "literal Char in hover info #1016"
11491156
, test no broken txtL8 litT "literal Text in hover info #1016"
11501157
, test no broken lstL43 litL "literal List in hover info #1016"
1158+
, test yes yes cmtL68 lackOfdEq "no Core symbols #3280"
11511159
, if ghcVersion >= GHC90 then
11521160
test no yes docL41 constr "type constraint in hover info #1012"
11531161
else
@@ -2329,6 +2337,7 @@ data Expect
23292337
-- | ExpectDefRange Range -- Only gotoDef should report this range
23302338
| ExpectHoverRange Range -- Only hover should report this range
23312339
| ExpectHoverText [T.Text] -- the hover message must contain these snippets
2340+
| ExpectHoverExcludeText [T.Text] -- the hover message must _not_ contain these snippets
23322341
| ExpectHoverTextRegex T.Text -- the hover message must match this pattern
23332342
| ExpectExternFail -- definition lookup in other file expected to fail
23342343
| ExpectNoDefinitions

0 commit comments

Comments
 (0)