From 5eb4902883d9d3937641d6a2c6249993242bf098 Mon Sep 17 00:00:00 2001 From: Pawel Szulc Date: Fri, 24 Jan 2020 21:30:55 +0100 Subject: Fix records with comments (#257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- tests/Language/Haskell/Stylish/Step/Data/Tests.hs | 65 +++++++++++++++-------- 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'tests') 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 @@ -287,6 +288,26 @@ case14 = expected @=? testStep (step 2) input 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" @@ -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" , " }" ] -- cgit v1.2.3