diff options
author | Maxim Koltsov <kolmax94@gmail.com> | 2020-02-02 15:18:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 13:18:24 +0100 |
commit | 41dcda2a34b5f12f3fa91480bfe2aaeb4afa90e5 (patch) | |
tree | 84f661b8d74b8a6525ed1c24d3319b053ae1f151 /tests | |
parent | d2594404a89839edc3ac44ea1fed3f99c2aade68 (diff) | |
download | stylish-haskell-41dcda2a34b5f12f3fa91480bfe2aaeb4afa90e5.tar.gz |
Disable formatting of data types without records (#265)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Language/Haskell/Stylish/Step/Data/Tests.hs | 20 | ||||
-rw-r--r-- | tests/Language/Haskell/Stylish/Tests.hs | 8 |
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/Language/Haskell/Stylish/Step/Data/Tests.hs b/tests/Language/Haskell/Stylish/Step/Data/Tests.hs index 712ffae..ff5ca3b 100644 --- a/tests/Language/Haskell/Stylish/Step/Data/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/Data/Tests.hs @@ -30,6 +30,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Data.Tests" , testCase "case 17" case17 , testCase "case 18" case18 , testCase "case 19" case19 + , testCase "case 20 (issue 262)" case20 ] case00 :: Assertion @@ -155,7 +156,7 @@ case07 = expected @=? testStep (step 2) input expected = input case08 :: Assertion -case08 = expected @=? testStep (step 2) input +case08 = input @=? testStep (step 2) input where input = unlines [ "module Herp where" @@ -163,11 +164,6 @@ case08 = expected @=? testStep (step 2) input , "data Phantom a =" , " Phantom" ] - expected = unlines - [ "module Herp where" - , "" - , "data Phantom a = Phantom" - ] case09 :: Assertion case09 = expected @=? testStep (step 4) input @@ -389,3 +385,15 @@ case19 = expected @=? testStep (step 2) input , " , age :: Int" , " }" ] + +-- | Should not break Enums (data without records) formating +-- +-- See https://github.com/jaspervdj/stylish-haskell/issues/262 +case20 :: Assertion +case20 = input @=? testStep (step 2) input + where + input = unlines + [ "module Herp where" + , "" + , "data Tag = Title | Text deriving (Eq, Show)" + ] diff --git a/tests/Language/Haskell/Stylish/Tests.hs b/tests/Language/Haskell/Stylish/Tests.hs index 3a27ce7..59ca92b 100644 --- a/tests/Language/Haskell/Stylish/Tests.hs +++ b/tests/Language/Haskell/Stylish/Tests.hs @@ -28,10 +28,12 @@ tests = testGroup "Language.Haskell.Stylish.Step.Tabs.Tests" case01 :: Assertion case01 = (@?= result) =<< format Nothing Nothing input where - input = "module Herp where\n data Foo = Bar | Baz" + input = "module Herp where\ndata Foo = Bar | Baz { baz :: Int }" result = Right [ "module Herp where" , "data Foo = Bar" , " | Baz" + , " { baz :: Int" + , " }" ] @@ -47,10 +49,12 @@ case02 = withTestDirTree $ do actual <- format (Just $ ConfigPath "test-config.yaml") Nothing input actual @?= result where - input = "module Herp where\n data Foo = Bar | Baz" + input = "module Herp where\ndata Foo = Bar | Baz { baz :: Int }" result = Right [ "module Herp where" , "data Foo = Bar" , " | Baz" + , " { baz :: Int" + , " }" ] |