summaryrefslogtreecommitdiffhomepage
path: root/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Language/Haskell/Stylish/Step/Imports/Tests.hs')
-rw-r--r--tests/Language/Haskell/Stylish/Step/Imports/Tests.hs89
1 files changed, 55 insertions, 34 deletions
diff --git a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
index 760018a..22031d4 100644
--- a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
+++ b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
@@ -58,6 +58,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Imports.Tests"
, testCase "case 24" case24
, testCase "case 25" case25
, testCase "case 26 (issue 185)" case26
+ , testCase "case 27" case27
]
@@ -82,7 +83,7 @@ input = unlines
--------------------------------------------------------------------------------
case01 :: Assertion
-case01 = expected @=? testStep (step 80 $ fromImportAlign Global) input
+case01 = expected @=? testStep (step (Just 80) $ fromImportAlign Global) input
where
expected = unlines
[ "module Herp where"
@@ -104,7 +105,7 @@ case01 = expected @=? testStep (step 80 $ fromImportAlign Global) input
--------------------------------------------------------------------------------
case02 :: Assertion
-case02 = expected @=? testStep (step 80 $ fromImportAlign Group) input
+case02 = expected @=? testStep (step (Just 80) $ fromImportAlign Group) input
where
expected = unlines
[ "module Herp where"
@@ -125,7 +126,7 @@ case02 = expected @=? testStep (step 80 $ fromImportAlign Group) input
--------------------------------------------------------------------------------
case03 :: Assertion
-case03 = expected @=? testStep (step 80 $ fromImportAlign None) input
+case03 = expected @=? testStep (step (Just 80) $ fromImportAlign None) input
where
expected = unlines
[ "module Herp where"
@@ -146,7 +147,7 @@ case03 = expected @=? testStep (step 80 $ fromImportAlign None) input
--------------------------------------------------------------------------------
case04 :: Assertion
-case04 = expected @=? testStep (step 80 $ fromImportAlign Global) input'
+case04 = expected @=? testStep (step (Just 80) $ fromImportAlign Global) input'
where
input' =
"import Data.Aeson.Types (object, typeMismatch, FromJSON(..)," ++
@@ -161,7 +162,7 @@ case04 = expected @=? testStep (step 80 $ fromImportAlign Global) input'
--------------------------------------------------------------------------------
case05 :: Assertion
-case05 = input' @=? testStep (step 80 $ fromImportAlign Group) input'
+case05 = input' @=? testStep (step (Just 80) $ fromImportAlign Group) input'
where
input' = "import Distribution.PackageDescription.Configuration " ++
"(finalizePackageDescription)\n"
@@ -169,7 +170,7 @@ case05 = input' @=? testStep (step 80 $ fromImportAlign Group) input'
--------------------------------------------------------------------------------
case06 :: Assertion
-case06 = input' @=? testStep (step 80 $ fromImportAlign File) input'
+case06 = input' @=? testStep (step (Just 80) $ fromImportAlign File) input'
where
input' = unlines
[ "import Bar.Qux"
@@ -179,7 +180,7 @@ case06 = input' @=? testStep (step 80 $ fromImportAlign File) input'
--------------------------------------------------------------------------------
case07 :: Assertion
-case07 = expected @=? testStep (step 80 $ fromImportAlign File) input'
+case07 = expected @=? testStep (step (Just 80) $ fromImportAlign File) input'
where
input' = unlines
[ "import Bar.Qux"
@@ -197,7 +198,7 @@ case07 = expected @=? testStep (step 80 $ fromImportAlign File) input'
--------------------------------------------------------------------------------
case08 :: Assertion
case08 = expected
- @=? testStep (step 80 $ Options Global WithAlias True Inline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 80) $ Options Global WithAlias True Inline Inherit (LPConstant 4) True False) input
where
expected = unlines
[ "module Herp where"
@@ -220,7 +221,7 @@ case08 = expected
--------------------------------------------------------------------------------
case08b :: Assertion
case08b = expected
- @=? testStep (step 80 $ Options Global WithModuleName True Inline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 80) $ Options Global WithModuleName True Inline Inherit (LPConstant 4) True False) input
where
expected = unlines
["module Herp where"
@@ -242,7 +243,7 @@ case08b = expected
--------------------------------------------------------------------------------
case09 :: Assertion
case09 = expected
- @=? testStep (step 80 $ Options Global WithAlias True Multiline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 80) $ Options Global WithAlias True Multiline Inherit (LPConstant 4) True False) input
where
expected = unlines
[ "module Herp where"
@@ -276,7 +277,7 @@ case09 = expected
--------------------------------------------------------------------------------
case10 :: Assertion
case10 = expected
- @=? testStep (step 40 $ Options Group WithAlias True Multiline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 40) $ Options Group WithAlias True Multiline Inherit (LPConstant 4) True False) input
where
expected = unlines
[ "module Herp where"
@@ -315,7 +316,7 @@ case10 = expected
--------------------------------------------------------------------------------
case11 :: Assertion
case11 = expected
- @=? testStep (step 80 $ Options Group NewLine True Inline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 80) $ Options Group NewLine True Inline Inherit (LPConstant 4) True False) input
where
expected = unlines
[ "module Herp where"
@@ -342,7 +343,7 @@ case11 = expected
case11b :: Assertion
case11b = expected
- @=? testStep (step 80 $ Options Group WithModuleName True Inline Inherit (LPConstant 4) True False) input
+ @=? testStep (step (Just 80) $ Options Group WithModuleName True Inline Inherit (LPConstant 4) True False) input
where
expected = unlines
[ "module Herp where"
@@ -364,7 +365,7 @@ case11b = expected
--------------------------------------------------------------------------------
case12 :: Assertion
case12 = expected
- @=? testStep (step 80 $ Options Group NewLine True Inline Inherit (LPConstant 2) True False) input'
+ @=? testStep (step (Just 80) $ Options Group NewLine True Inline Inherit (LPConstant 2) True False) input'
where
input' = unlines
[ "import Data.List (map)"
@@ -379,7 +380,7 @@ case12 = expected
--------------------------------------------------------------------------------
case12b :: Assertion
case12b = expected
- @=? testStep (step 80 $ Options Group WithModuleName True Inline Inherit (LPConstant 2) True False) input'
+ @=? testStep (step (Just 80) $ Options Group WithModuleName True Inline Inherit (LPConstant 2) True False) input'
where
input' = unlines
[ "import Data.List (map)"
@@ -391,7 +392,7 @@ case12b = expected
--------------------------------------------------------------------------------
case13 :: Assertion
case13 = expected
- @=? testStep (step 80 $ Options None WithAlias True InlineWithBreak Inherit (LPConstant 4) True False) input'
+ @=? testStep (step (Just 80) $ Options None WithAlias True InlineWithBreak Inherit (LPConstant 4) True False) input'
where
input' = unlines
[ "import qualified Data.List as List (concat, foldl, foldr, head, init,"
@@ -408,7 +409,7 @@ case13 = expected
--------------------------------------------------------------------------------
case13b :: Assertion
case13b = expected
- @=? testStep (step 80 $ Options None WithModuleName True InlineWithBreak Inherit (LPConstant 4) True False) input'
+ @=? testStep (step (Just 80) $ Options None WithModuleName True InlineWithBreak Inherit (LPConstant 4) True False) input'
where
input' = unlines
[ "import qualified Data.List as List (concat, foldl, foldr, head, init,"
@@ -426,7 +427,7 @@ case13b = expected
case14 :: Assertion
case14 = expected
@=? testStep
- (step 80 $ Options None WithAlias True InlineWithBreak Inherit (LPConstant 10) True False) expected
+ (step (Just 80) $ Options None WithAlias True InlineWithBreak Inherit (LPConstant 10) True False) expected
where
expected = unlines
[ "import qualified Data.List as List (concat, map, null, reverse, tail, (++))"
@@ -436,7 +437,7 @@ case14 = expected
--------------------------------------------------------------------------------
case15 :: Assertion
case15 = expected
- @=? testStep (step 80 $ Options None AfterAlias True Multiline Inherit (LPConstant 4) True False) input'
+ @=? testStep (step (Just 80) $ Options None AfterAlias True Multiline Inherit (LPConstant 4) True False) input'
where
expected = unlines
[ "import Data.Acid (AcidState)"
@@ -462,7 +463,7 @@ case15 = expected
--------------------------------------------------------------------------------
case16 :: Assertion
case16 = expected
- @=? testStep (step 80 $ Options None AfterAlias True Multiline Inherit (LPConstant 4) False False) input'
+ @=? testStep (step (Just 80) $ Options None AfterAlias True Multiline Inherit (LPConstant 4) False False) input'
where
expected = unlines
[ "import Data.Acid (AcidState)"
@@ -486,7 +487,7 @@ case16 = expected
--------------------------------------------------------------------------------
case17 :: Assertion
case17 = expected
- @=? testStep (step 80 $ Options None AfterAlias True Multiline Inherit (LPConstant 4) True False) input'
+ @=? testStep (step (Just 80) $ Options None AfterAlias True Multiline Inherit (LPConstant 4) True False) input'
where
expected = unlines
[ "import Control.Applicative (Applicative (pure, (<*>)))"
@@ -504,7 +505,7 @@ case17 = expected
--------------------------------------------------------------------------------
case18 :: Assertion
case18 = expected @=? testStep
- (step 40 $ Options None AfterAlias True InlineToMultiline Inherit (LPConstant 4) True False) input'
+ (step (Just 40) $ Options None AfterAlias True InlineToMultiline Inherit (LPConstant 4) True False) input'
where
expected = unlines
----------------------------------------
@@ -532,7 +533,7 @@ case18 = expected @=? testStep
--------------------------------------------------------------------------------
case19 :: Assertion
case19 = expected @=? testStep
- (step 40 $ Options Global NewLine True InlineWithBreak RightAfter (LPConstant 17) True False) case19input
+ (step (Just 40) $ Options Global NewLine True InlineWithBreak RightAfter (LPConstant 17) True False) case19input
where
expected = unlines
----------------------------------------
@@ -548,7 +549,7 @@ case19 = expected @=? testStep
case19b :: Assertion
case19b = expected @=? testStep
- (step 40 $ Options File NewLine True InlineWithBreak RightAfter (LPConstant 17) True False) case19input
+ (step (Just 40) $ Options File NewLine True InlineWithBreak RightAfter (LPConstant 17) True False) case19input
where
expected = unlines
----------------------------------------
@@ -564,7 +565,7 @@ case19b = expected @=? testStep
case19c :: Assertion
case19c = expected @=? testStep
- (step 40 $ Options File NewLine True InlineWithBreak RightAfter LPModuleName True False) case19input
+ (step (Just 40) $ Options File NewLine True InlineWithBreak RightAfter LPModuleName True False) case19input
where
expected = unlines
----------------------------------------
@@ -580,7 +581,7 @@ case19c = expected @=? testStep
case19d :: Assertion
case19d = expected @=? testStep
- (step 40 $ Options Global NewLine True InlineWithBreak RightAfter LPModuleName True False) case19input
+ (step (Just 40) $ Options Global NewLine True InlineWithBreak RightAfter LPModuleName True False) case19input
where
expected = unlines
----------------------------------------
@@ -606,7 +607,7 @@ case19input = unlines
--------------------------------------------------------------------------------
case20 :: Assertion
case20 = expected
- @=? testStep (step 80 defaultOptions) input'
+ @=? testStep (step (Just 80) defaultOptions) input'
where
expected = unlines
[ "import {-# SOURCE #-} Data.ByteString as BS"
@@ -625,7 +626,7 @@ case20 = expected
--------------------------------------------------------------------------------
case21 :: Assertion
case21 = expected
- @=? testStep (step 80 defaultOptions) input'
+ @=? testStep (step (Just 80) defaultOptions) input'
where
expected = unlines
[ "{-# LANGUAGE ExplicitNamespaces #-}"
@@ -656,7 +657,7 @@ case21 = expected
--------------------------------------------------------------------------------
case22 :: Assertion
case22 = expected
- @=? testStep (step 80 defaultOptions) input'
+ @=? testStep (step (Just 80) defaultOptions) input'
where
expected = unlines
[ "{-# LANGUAGE PackageImports #-}"
@@ -683,7 +684,7 @@ case22 = expected
--------------------------------------------------------------------------------
case23 :: Assertion
case23 = expected
- @=? testStep (step 40 $ Options None AfterAlias False Inline Inherit (LPConstant 4) True True) input'
+ @=? testStep (step (Just 40) $ Options None AfterAlias False Inline Inherit (LPConstant 4) True True) input'
where
expected = unlines
[ "import Data.Acid ( AcidState )"
@@ -708,7 +709,7 @@ case23 = expected
--------------------------------------------------------------------------------
case23b :: Assertion
case23b = expected
- @=? testStep (step 40 $ Options None WithModuleName False Inline Inherit (LPConstant 4) True True) input'
+ @=? testStep (step (Just 40) $ Options None WithModuleName False Inline Inherit (LPConstant 4) True True) input'
where
expected = unlines
[ "import Data.Acid ( AcidState )"
@@ -734,7 +735,7 @@ case23b = expected
--------------------------------------------------------------------------------
case24 :: Assertion
case24 = expected
- @=? testStep (step 40 $ Options None AfterAlias False InlineWithBreak Inherit (LPConstant 4) True True) input'
+ @=? testStep (step (Just 40) $ Options None AfterAlias False InlineWithBreak Inherit (LPConstant 4) True True) input'
where
expected = unlines
[ "import Data.Acid ( AcidState )"
@@ -758,7 +759,7 @@ case24 = expected
--------------------------------------------------------------------------------
case25 :: Assertion
case25 = expected
- @=? testStep (step 80 $ Options Group AfterAlias False Multiline Inherit (LPConstant 4) False False) input'
+ @=? testStep (step (Just 80) $ Options Group AfterAlias False Multiline Inherit (LPConstant 4) False False) input'
where
expected = unlines
[ "import Data.Acid (AcidState)"
@@ -783,7 +784,7 @@ case25 = expected
--------------------------------------------------------------------------------
case26 :: Assertion
case26 = expected
- @=? testStep (step 80 options ) input'
+ @=? testStep (step (Just 80) options ) input'
where
options = defaultOptions { listAlign = NewLine, longListAlign = Multiline }
input' = unlines
@@ -792,3 +793,23 @@ case26 = expected
expected = unlines
[ "import Data.List"
]
+
+
+--------------------------------------------------------------------------------
+case27 :: Assertion
+case27 = expected @=? testStep (step Nothing $ fromImportAlign Global) input
+ where
+ expected = unlines
+ [ "module Herp where"
+ , ""
+ , "import Control.Monad"
+ , "import Data.List as List (concat, foldl, foldr, head, init, last, length, map, null, reverse, tail, (++))"
+ , "import Data.Map (Map, insert, lookup, (!))"
+ , "import qualified Data.Map as M"
+ , "import Only.Instances ()"
+ , ""
+ , "import Foo (Bar (..))"
+ , "import Herp.Derp.Internals hiding (foo)"
+ , ""
+ , "herp = putStrLn \"import Hello world\""
+ ]