Skip to content

Commit

Permalink
Add class plugin test for _
Browse files Browse the repository at this point in the history
  • Loading branch information
Ailrun committed Jan 7, 2021
1 parent 379f590 commit 645f141
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/functional/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ tests = testGroup
, glodenTest "Creates a placeholder for multiple methods 2" "T3" "2"
$ \(_:mmAction:_) -> do
executeCodeAction mmAction
, glodenTest "Creates a placeholder for a method starting with '_'" "T4" ""
$ \(_:mmAction:_) -> do
executeCodeAction mmAction
]

_CACodeAction :: Prism' CAResult CodeAction
Expand All @@ -60,14 +63,18 @@ classPath = "test" </> "testdata" </> "class"

glodenTest :: String -> FilePath -> FilePath -> ([CodeAction] -> Session ()) -> TestTree
glodenTest name fp deco execute
= goldenVsStringDiff name goldenGitDiff (classPath </> fp <.> deco <.> "expected" <.> "hs")
= goldenVsStringDiff name goldenGitDiff (classPath </> fpWithDeco <.> "expected" <.> "hs")
$ runSession hlsCommand fullCaps classPath
$ do
doc <- openDoc (fp <.> "hs") "haskell"
_ <- waitForDiagnosticsFromSource doc "typecheck"
actions <- concatMap (^.. _CACodeAction) <$> getAllCodeActions doc
execute actions
BS.fromStrict . T.encodeUtf8 <$> getDocumentEdit doc
where
fpWithDeco
| deco == "" = fp
| otherwise = fp <.> deco

goldenGitDiff :: FilePath -> FilePath -> [String]
goldenGitDiff fRef fNew = ["git", "diff", "--no-index", "--text", "--exit-code", fRef, fNew]
7 changes: 7 additions & 0 deletions test/testdata/class/T4.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module T4 where

class Test a where
_f :: a
{-# MINIMAL f #-}

instance Test Int where

0 comments on commit 645f141

Please sign in to comment.