Skip to content

Fix toMethodName bug of the Class plugin #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add class plugin test for _
  • Loading branch information
Ailrun committed Jan 7, 2021
commit d4e666a8fc7af9b58e31d0336a83602cfb8d0bfd
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" ""
$ \(_fAction:_) -> do
executeCodeAction _fAction
]

_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]
8 changes: 8 additions & 0 deletions test/testdata/class/T4.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module T4 where

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

instance Test Int where
_f = _
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