Skip to content

Commit

Permalink
Rename test files
Browse files Browse the repository at this point in the history
  • Loading branch information
July541 committed Jun 22, 2022
1 parent 558cd9d commit da6b074
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 58 deletions.
32 changes: 17 additions & 15 deletions plugins/hls-class-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tests recorder = testGroup
"class"
[codeActionTests recorder , codeLensTests recorder]

-- codeActionTests :: TestTree
codeActionTests :: Recorder (WithPriority Class.Log) -> TestTree
codeActionTests recorder = testGroup
"code actions"
[ testCase "Produces addMinimalMethodPlaceholders code actions for one instance" $ do
Expand Down Expand Up @@ -70,22 +70,22 @@ codeActionTests recorder = testGroup
, goldenWithClass recorder "Creates a placeholder for other two methods" "T6" "2" $ \(_:_:ghAction:_) -> do
executeCodeAction ghAction
, onlyRunForGhcVersions [GHC92] "Only ghc-9.2 enabled GHC2021 implicitly" $
goldenWithClass recorder "Don't insert pragma with GHC2021" "T16" "" $ \(_:eqWithSig:_) -> do
goldenWithClass recorder "Don't insert pragma with GHC2021" "InsertWithGHC2021Enabled" "" $ \(_:eqWithSig:_) -> do
executeCodeAction eqWithSig
, goldenWithClass recorder "Insert pragma if not exist" "T7" "" $ \(_:eqWithSig:_) -> do
, goldenWithClass recorder "Insert pragma if not exist" "InsertWithoutPragma" "" $ \(_:eqWithSig:_) -> do
executeCodeAction eqWithSig
, goldenWithClass recorder "Don't insert pragma if exist" "T8" "" $ \(_:eqWithSig:_) -> do
, goldenWithClass recorder "Don't insert pragma if exist" "InsertWithPragma" "" $ \(_:eqWithSig:_) -> do
executeCodeAction eqWithSig
, goldenWithClass recorder "Only insert pragma once" "T9" "" $ \(_:multi:_) -> do
, goldenWithClass recorder "Only insert pragma once" "InsertPragmaOnce" "" $ \(_:multi:_) -> do
executeCodeAction multi
]

-- codeLensTests :: TestTree
codeLensTests :: Recorder (WithPriority Class.Log) -> TestTree
codeLensTests recorder = testGroup
"code lens"
[ testCase "Has code lens" $ do
runSessionWithServer (classPlugin recorder) testDataDir $ do
doc <- openDoc "T10.hs" "haskell"
doc <- openDoc "CodeLensSimple.hs" "haskell"
lens <- getCodeLenses doc
let titles = map (^. J.title) $ mapMaybe (^. J.command) lens
liftIO $ titles @?=
Expand All @@ -97,25 +97,27 @@ codeLensTests recorder = testGroup
sendConfigurationChanged
$ toJSON
$ def { Plugin.plugins = [("class", def { plcConfig = "typelensOn" .= False })] }
doc <- openDoc "T10.hs" "haskell"
doc <- openDoc "CodeLensSimple.hs" "haskell"
lens <- getCodeLenses doc
let titles = map (^. J.title) $ mapMaybe (^. J.command) lens
liftIO $ titles @?= []
, goldenCodeLens recorder "Apply code lens" "T10" 1
, goldenCodeLens recorder "Apply code lens for local class" "T11" 0
, goldenCodeLens recorder "Apply code lens on the same line" "T12" 0
, goldenCodeLens recorder "Don't insert pragma while existing" "T13" 0
, goldenCodeLens recorder "Apply code lens" "CodeLensSimple" 1
, goldenCodeLens recorder "Apply code lens for local class" "LocalClassDefine" 0
, goldenCodeLens recorder "Apply code lens on the same line" "Inline" 0
, goldenCodeLens recorder "Don't insert pragma while existing" "CodeLensWithPragma" 0
, onlyRunForGhcVersions [GHC92] "Only ghc-9.2 enabled GHC2021 implicitly" $
goldenCodeLens recorder "Don't insert pragma while GHC2021 enabled" "T14" 0
, goldenCodeLens recorder "Qualified name" "T15" 0
goldenCodeLens recorder "Don't insert pragma while GHC2021 enabled" "CodeLensWithGHC2021" 0
, goldenCodeLens recorder "Qualified name" "Qualified" 0
, goldenCodeLens recorder "Type family" "TypeFamily" 0
]

_CACodeAction :: Prism' (Command |? CodeAction) CodeAction
_CACodeAction = prism' InR $ \case
InR action -> Just action
_ -> Nothing

-- goldenCodeLens :: TestName -> FilePath -> Int -> TestTree

goldenCodeLens :: Recorder (WithPriority Class.Log) -> TestName -> FilePath -> Int -> TestTree
goldenCodeLens recorder title path idx =
goldenWithHaskellDoc (classPlugin recorder) title testDataDir path "expected" "hs" $ \doc -> do
lens <- getCodeLenses doc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T10 where
module CodeLensSimple where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T10 where
module CodeLensSimple where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE GHC2021 #-}
module T14 where
module CodeLensWithGHC2021 where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE GHC2021 #-}
module T14 where
module CodeLensWithGHC2021 where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T13 where
module CodeLensWithPragma where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T13 where
module CodeLensWithPragma where

data A
instance Eq A where
Expand Down
6 changes: 6 additions & 0 deletions plugins/hls-class-plugin/test/testdata/Inline.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{-# LANGUAGE InstanceSigs #-}
module Inline where

data A
instance Eq A where (==) :: A -> A -> Bool
(==) = _
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T12 where
module Inline where

data A
instance Eq A where (==) = _
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T9 where
module InsertPragmaOnce where

data A aaa
instance Applicative A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T9 where
module InsertPragmaOnce where

data A aaa
instance Applicative A
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T12 where
{-# LANGUAGE GHC2021#-}
module InsertWithGHC2021Enabled where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE GHC2021#-}
module T16 where
module InsertWithGHC2021Enabled where

data A
instance Eq A
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T7 where
module InsertWithPragma where

data A
instance Eq A where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T8 where
module InsertWithPragma where

data A
instance Eq A
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T8 where
module InsertWithoutPragma where

data A
instance Eq A where
Expand Down
4 changes: 4 additions & 0 deletions plugins/hls-class-plugin/test/testdata/InsertWithoutPragma.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module InsertWithoutPragma where

data A
instance Eq A
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE InstanceSigs #-}
module T11 where
module LocalClassDefine where

data A
class F a where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T11 where
module LocalClassDefine where

data A
class F a where
Expand Down
10 changes: 10 additions & 0 deletions plugins/hls-class-plugin/test/testdata/Qualified.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE InstanceSigs #-}
module Qualified where
import qualified QualifiedA

class F a where
f :: a

instance F QualifiedA.A where
f :: QualifiedA.A
f = undefined
8 changes: 8 additions & 0 deletions plugins/hls-class-plugin/test/testdata/Qualified.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Qualified where
import qualified QualifiedA

class F a where
f :: a

instance F QualifiedA.A where
f = undefined
3 changes: 3 additions & 0 deletions plugins/hls-class-plugin/test/testdata/QualifiedA.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module QualifiedA where

data A
10 changes: 0 additions & 10 deletions plugins/hls-class-plugin/test/testdata/T15.expected.hs

This file was deleted.

8 changes: 0 additions & 8 deletions plugins/hls-class-plugin/test/testdata/T15.hs

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/hls-class-plugin/test/testdata/T15A.hs

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/hls-class-plugin/test/testdata/T7.hs

This file was deleted.

11 changes: 11 additions & 0 deletions plugins/hls-class-plugin/test/testdata/TypeFamily.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE InstanceSigs #-}
module TypeFamily where

class F a where
type Elem a
f :: Elem a -> a

instance Eq a => F [a] where
f :: Eq a => Elem [a] -> [a]
f = _
9 changes: 9 additions & 0 deletions plugins/hls-class-plugin/test/testdata/TypeFamily.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{-# LANGUAGE TypeFamilies #-}
module TypeFamily where

class F a where
type Elem a
f :: Elem a -> a

instance Eq a => F [a] where
f = _
2 changes: 1 addition & 1 deletion plugins/hls-class-plugin/test/testdata/hie.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cradle:
direct:
arguments: [-XHaskell2010, T15A]
arguments: [-XHaskell2010, QualifiedA]

0 comments on commit da6b074

Please sign in to comment.