diff options
author | Pawel Szulc <paul.szulc@gmail.com> | 2020-01-24 21:30:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-24 21:30:55 +0100 |
commit | 5eb4902883d9d3937641d6a2c6249993242bf098 (patch) | |
tree | 8ac7462900d30d9a020f3e6a07580f218b708693 /tests | |
parent | 8065c3c074719bd13db67b5ec74db560609a4e64 (diff) | |
download | stylish-haskell-5eb4902883d9d3937641d6a2c6249993242bf098.tar.gz |
Fix records with comments (#257)
* Format records where comments are in the same line as the field name
* Fix records format, records with comments will now be formatted
* Fix formatting of comments below
Co-authored-by: Łukasz Gołębiewski <lukasz.golebiewski@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Language/Haskell/Stylish/Step/Data/Tests.hs | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/tests/Language/Haskell/Stylish/Step/Data/Tests.hs b/tests/Language/Haskell/Stylish/Step/Data/Tests.hs index b152819..712ffae 100644 --- a/tests/Language/Haskell/Stylish/Step/Data/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/Data/Tests.hs @@ -29,6 +29,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests" , testCase "case 16" case16 , testCase "case 17" case17 , testCase "case 18" case18 + , testCase "case 19" case19 ] case00 :: Assertion @@ -289,6 +290,26 @@ case15 :: Assertion case15 = expected @=? testStep (step 2) input where input = unlines + [ "module Herp where" + , "" + , "data Foo a = Foo" + , " { a :: a, -- comment" + , " a2 :: String" + , " }" + ] + expected = unlines + [ "module Herp where" + , "" + , "data Foo a = Foo" + , " { a :: a -- comment" + , " , a2 :: String" + , " }" + ] + +case16 :: Assertion +case16 = expected @=? testStep (step 2) input + where + input = unlines [ "module Herp where" , "" , "data Foo = Foo {" @@ -298,20 +319,20 @@ case15 = expected @=? testStep (step 2) input expected = unlines [ "module Herp where" , "" - , "data Foo = Foo {" - , " a :: Int -- ^ comment" + , "data Foo = Foo" + , " { a :: Int -- ^ comment" , " }" ] -case16 :: Assertion -case16 = expected @=? testStep (step 2) input +case17 :: Assertion +case17 = expected @=? testStep (step 2) input where input = unlines [ "module Herp where" , "" , "data Foo a = Foo" , " { a :: a," - , "-- ^ comment" + , "-- comment" , " a2 :: String" , " }" ] @@ -319,20 +340,21 @@ case16 = expected @=? testStep (step 2) input [ "module Herp where" , "" , "data Foo a = Foo" - , " { a :: a," - , "-- ^ comment" - , " a2 :: String" + , " { a :: a" + , " -- comment" + , " , a2 :: String" , " }" ] -case17 :: Assertion -case17 = expected @=? testStep (step 2) input +case18 :: Assertion +case18 = expected @=? testStep (step 2) input where input = unlines [ "module Herp where" , "" , "data Foo a = Foo" - , " { a :: a, -- comment" + , " { a :: a," + , "-- ^ comment" , " a2 :: String" , " }" ] @@ -340,29 +362,30 @@ case17 = expected @=? testStep (step 2) input [ "module Herp where" , "" , "data Foo a = Foo" - , " { a :: a, -- comment" - , " a2 :: String" + , " { a :: a" + , " -- ^ comment" + , " , a2 :: String" , " }" ] -case18 :: Assertion -case18 = expected @=? testStep (step 2) input +case19 :: Assertion +case19 = expected @=? testStep (step 2) input where input = unlines [ "module Herp where" , "" , "data Foo a = Foo" - , " { a :: a," - , "-- comment " - , " a2 :: String" + , " { firstName, lastName :: String," + , "-- ^ names" + , " age :: Int" , " }" ] expected = unlines [ "module Herp where" , "" , "data Foo a = Foo" - , " { a :: a," - , "-- comment " - , " a2 :: String" + , " { firstName, lastName :: String" + , " -- ^ names" + , " , age :: Int" , " }" ] |