Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kokobd committed Sep 21, 2022
1 parent 481acf4 commit 88f063f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Language.Haskell.GHC.ExactPrint.Utils (mkComment)
genForDataDecl :: GenComments
genForDataDecl =
GenComments {
title = "Generate fields comments",
title = "Generate haddock comments",
updateAnns = updateDataAnns
}

Expand Down
6 changes: 4 additions & 2 deletions plugins/hls-haddock-comments-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ tests =
goldenWithHaddockComments "MultivariateFunction" Signature 4 8,
goldenWithHaddockComments "QualFunction" Signature 2 10,
goldenWithHaddockComments "Record" Record 7 2,
goldenWithHaddockComments "Record2" Record 3 6,
goldenWithHaddockComments "InlineRecord" Record 3 20,
expectedNothing "ConstFunction" Signature 2 2,
expectedNothing "StaleFunction" Signature 3 3,
expectedNothing "StaleRecord" Record 3 12
expectedNothing "StaleRecord" Record 4 9
]

goldenWithHaddockComments :: FilePath -> GenCommentsType -> UInt -> UInt -> TestTree
Expand All @@ -54,7 +56,7 @@ data GenCommentsType = Signature | Record

toTitle :: GenCommentsType -> Text
toTitle Signature = "Generate signature comments"
toTitle Record = "Generate fields comments"
toTitle Record = "Generate haddock comments"

caTitle :: (Command |? CodeAction) -> Maybe Text
caTitle (InR CodeAction {_title}) = Just _title
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Record2 where

-- | A record
data Record = -- |
A { -- |
a :: Int , -- |
b :: String }
| -- |
B { -- |
bb :: Double }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Record2 where

-- | A record
data Record = A { a :: Int , b :: String } | B { bb :: Double }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Record2 where

-- | A record
data Record = -- |
RecordA
{ -- |
a :: Int
, -- |
b :: String
}
7 changes: 7 additions & 0 deletions plugins/hls-haddock-comments-plugin/test/testdata/Record2.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Record2 where

-- | A record
data Record = RecordA
{ a :: Int
, b :: String
}

0 comments on commit 88f063f

Please sign in to comment.