diff options
Diffstat (limited to 'tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs')
-rw-r--r-- | tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs b/tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs index 827022c..e30f0ba 100644 --- a/tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/SimpleAlign/Tests.hs @@ -33,6 +33,10 @@ tests = testGroup "Language.Haskell.Stylish.Step.SimpleAlign.Tests" , testCase "case 12" case12 , testCase "case 13" case13 , testCase "case 13b" case13b + , testCase "case 14" case14 + , testCase "case 15" case15 + , testCase "case 16" case16 + , testCase "case 17" case17 ] @@ -194,7 +198,7 @@ case11 = assertSnippet (step Nothing defaultConfig) -------------------------------------------------------------------------------- case12 :: Assertion -case12 = assertSnippet (step Nothing defaultConfig {cCases = False}) input input +case12 = assertSnippet (step Nothing defaultConfig { cCases = Never }) input input where input = [ "case x of" @@ -216,7 +220,7 @@ case13 = assertSnippet (step Nothing defaultConfig) ] case13b :: Assertion -case13b = assertSnippet (step Nothing defaultConfig {cMultiWayIf = False}) +case13b = assertSnippet (step Nothing defaultConfig {cMultiWayIf = Never}) [ "cond n = if" , " | n < 10, x <- 1 -> x" , " | otherwise -> 2" @@ -225,3 +229,77 @@ case13b = assertSnippet (step Nothing defaultConfig {cMultiWayIf = False}) , " | n < 10, x <- 1 -> x" , " | otherwise -> 2" ] + + +-------------------------------------------------------------------------------- +case14 :: Assertion +case14 = assertSnippet (step (Just 80) defaultConfig { cCases = Adjacent }) + [ "catch e = case e of" + , " Left GoodError -> 1" + , " Left BadError -> 2" + , " -- otherwise" + , " Right [] -> 0" + , " Right (x:_) -> x" + ] + [ "catch e = case e of" + , " Left GoodError -> 1" + , " Left BadError -> 2" + , " -- otherwise" + , " Right [] -> 0" + , " Right (x:_) -> x" + ] + + +-------------------------------------------------------------------------------- +case15 :: Assertion +case15 = assertSnippet (step (Just 80) defaultConfig { cTopLevelPatterns = Adjacent }) + [ "catch (Left GoodError) = 1" + , "catch (Left BadError) = 2" + , "-- otherwise" + , "catch (Right []) = 0" + , "catch (Right (x:_)) = x" + ] + [ "catch (Left GoodError) = 1" + , "catch (Left BadError) = 2" + , "-- otherwise" + , "catch (Right []) = 0" + , "catch (Right (x:_)) = x" + ] + + +-------------------------------------------------------------------------------- +case16 :: Assertion +case16 = assertSnippet (step (Just 80) defaultConfig { cRecords = Adjacent }) + [ "data Foo = Foo" + , " { foo :: Int" + , " , foo2 :: String" + , " -- a comment" + , " , barqux :: String" + , " , baz :: String" + , " , baz2 :: Bool" + , " } deriving (Show)" + ] + [ "data Foo = Foo" + , " { foo :: Int" + , " , foo2 :: String" + , " -- a comment" + , " , barqux :: String" + , " , baz :: String" + , " , baz2 :: Bool" + , " } deriving (Show)" + ] + + +-------------------------------------------------------------------------------- +case17 :: Assertion +case17 = assertSnippet (step Nothing defaultConfig { cMultiWayIf = Adjacent }) + [ "cond n = if" + , " | n < 10, x <- 1 -> x" + , " -- comment" + , " | otherwise -> 2" + ] + [ "cond n = if" + , " | n < 10, x <- 1 -> x" + , " -- comment" + , " | otherwise -> 2" + ] |