@@ -73,6 +73,8 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests"
7373 , testCase " case 58" case58
7474 , testCase " case 59" case59
7575 , testCase " case 60" case60
76+ , testCase " case 61 (issue 282)" case61
77+ , testCase " case 62 (issue 273)" case62
7678 ]
7779
7880case00 :: Assertion
@@ -1309,6 +1311,72 @@ case60 = assertSnippet (step defaultConfig)
13091311 [ " data Foo = forall a . Bar a" ]
13101312 [ " data Foo = forall a. Bar a" ]
13111313
1314+ -- | Formatting duplicates haddock comments #282
1315+ --
1316+ -- Regression test for https://github.com/haskell/stylish-haskell/issues/282
1317+ case61 :: Assertion
1318+ case61 = expected @=? testStep (step sameIndentStyle) input
1319+ where
1320+ input = unlines
1321+ [ " module Herp where"
1322+ , " "
1323+ , " data Game = Game { _board :: Board -- ^ Board state"
1324+ , " , _time :: Int -- ^ Time elapsed"
1325+ , " , _paused :: Bool -- ^ Playing vs. paused"
1326+ , " , _speed :: Float -- ^ Speed in [0..1]"
1327+ , " , _interval :: TVar Int -- ^ Interval kept in TVar"
1328+ , " }"
1329+ ]
1330+
1331+ expected = unlines
1332+ [ " module Herp where"
1333+ , " "
1334+ , " data Game = Game"
1335+ , " { _board :: Board"
1336+ , " -- ^ Board state"
1337+ , " , _time :: Int"
1338+ , " -- ^ Time elapsed"
1339+ , " , _paused :: Bool"
1340+ , " -- ^ Playing vs. paused"
1341+ , " , _speed :: Float"
1342+ , " -- ^ Speed in [0..1]"
1343+ , " , _interval :: TVar Int"
1344+ , " -- ^ Interval kept in TVar"
1345+ , " }"
1346+ ]
1347+
1348+ -- | Comment issues with record formatting #273
1349+ --
1350+ -- Regression test for https://github.com/haskell/stylish-haskell/issues/273
1351+ case62 :: Assertion
1352+ case62 = expected @=? testStep (step sameIndentStyle) input
1353+ where
1354+ input = unlines
1355+ [ " module Herp where"
1356+ , " "
1357+ , " data Foo = Foo"
1358+ , " { -- | This is a comment above some line."
1359+ , " -- It can span multiple lines."
1360+ , " fooName :: String"
1361+ , " , fooAge :: Int"
1362+ , " -- ^ This is a comment below some line."
1363+ , " -- It can span multiple lines."
1364+ , " }"
1365+ ]
1366+
1367+ expected = unlines
1368+ [ " module Herp where"
1369+ , " "
1370+ , " data Foo = Foo"
1371+ , " { -- | This is a comment above some line."
1372+ , " -- It can span multiple lines."
1373+ , " fooName :: String"
1374+ , " , fooAge :: Int"
1375+ , " -- ^ This is a comment below some line."
1376+ , " -- It can span multiple lines."
1377+ , " }"
1378+ ]
1379+
13121380sameSameStyle :: Config
13131381sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns
13141382
0 commit comments