From 03e1712b9da40c366f459b53555963e69eb288ec Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Tue, 9 May 2017 03:05:54 -0700 Subject: Add space_surround option to import styling --- .../Language/Haskell/Stylish/Step/Imports/Tests.hs | 79 ++++++++++++++++++---- 1 file changed, 64 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs index 02f7076..8f9abb7 100644 --- a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs @@ -49,6 +49,8 @@ tests = testGroup "Language.Haskell.Stylish.Step.Imports.Tests" , testCase "case 20" case20 , testCase "case 21" case21 , testCase "case 22" case22 + , testCase "case 23" case23 + , testCase "case 24" case24 ] @@ -188,7 +190,7 @@ case07 = expected @=? testStep (step 80 $ fromImportAlign File) input' -------------------------------------------------------------------------------- case08 :: Assertion case08 = expected - @=? testStep (step 80 $ Options Global WithAlias Inline Inherit (LPConstant 4) True) input + @=? testStep (step 80 $ Options Global WithAlias Inline Inherit (LPConstant 4) True False) input where expected = unlines [ "module Herp where" @@ -211,7 +213,7 @@ case08 = expected -------------------------------------------------------------------------------- case09 :: Assertion case09 = expected - @=? testStep (step 80 $ Options Global WithAlias Multiline Inherit (LPConstant 4) True) input + @=? testStep (step 80 $ Options Global WithAlias Multiline Inherit (LPConstant 4) True False) input where expected = unlines [ "module Herp where" @@ -245,7 +247,7 @@ case09 = expected -------------------------------------------------------------------------------- case10 :: Assertion case10 = expected - @=? testStep (step 40 $ Options Group WithAlias Multiline Inherit (LPConstant 4) True) input + @=? testStep (step 40 $ Options Group WithAlias Multiline Inherit (LPConstant 4) True False) input where expected = unlines [ "module Herp where" @@ -284,7 +286,7 @@ case10 = expected -------------------------------------------------------------------------------- case11 :: Assertion case11 = expected - @=? testStep (step 80 $ Options Group NewLine Inline Inherit (LPConstant 4) True) input + @=? testStep (step 80 $ Options Group NewLine Inline Inherit (LPConstant 4) True False) input where expected = unlines [ "module Herp where" @@ -312,7 +314,7 @@ case11 = expected -------------------------------------------------------------------------------- case12 :: Assertion case12 = expected - @=? testStep (step 80 $ Options Group NewLine Inline Inherit (LPConstant 2) True) input' + @=? testStep (step 80 $ Options Group NewLine Inline Inherit (LPConstant 2) True False) input' where input' = unlines [ "import Data.List (map)" @@ -327,7 +329,7 @@ case12 = expected -------------------------------------------------------------------------------- case13 :: Assertion case13 = expected - @=? testStep (step 80 $ Options None WithAlias InlineWithBreak Inherit (LPConstant 4) True) input' + @=? testStep (step 80 $ Options None WithAlias InlineWithBreak Inherit (LPConstant 4) True False) input' where input' = unlines [ "import qualified Data.List as List (concat, foldl, foldr, head, init," @@ -345,7 +347,7 @@ case13 = expected case14 :: Assertion case14 = expected @=? testStep - (step 80 $ Options None WithAlias InlineWithBreak Inherit (LPConstant 10) True) expected + (step 80 $ Options None WithAlias InlineWithBreak Inherit (LPConstant 10) True False) expected where expected = unlines [ "import qualified Data.List as List (concat, map, null, reverse, tail, (++))" @@ -355,7 +357,7 @@ case14 = expected -------------------------------------------------------------------------------- case15 :: Assertion case15 = expected - @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) True) input' + @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) True False) input' where expected = unlines [ "import Data.Acid (AcidState)" @@ -381,7 +383,7 @@ case15 = expected -------------------------------------------------------------------------------- case16 :: Assertion case16 = expected - @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) False) input' + @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) False False) input' where expected = unlines [ "import Data.Acid (AcidState)" @@ -405,7 +407,7 @@ case16 = expected -------------------------------------------------------------------------------- case17 :: Assertion case17 = expected - @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) True) input' + @=? testStep (step 80 $ Options None AfterAlias Multiline Inherit (LPConstant 4) True False) input' where expected = unlines [ "import Control.Applicative (Applicative (pure, (<*>)))" @@ -423,7 +425,7 @@ case17 = expected -------------------------------------------------------------------------------- case18 :: Assertion case18 = expected @=? testStep - (step 40 $ Options None AfterAlias InlineToMultiline Inherit (LPConstant 4) True) input' + (step 40 $ Options None AfterAlias InlineToMultiline Inherit (LPConstant 4) True False) input' where expected = unlines ---------------------------------------- @@ -450,7 +452,7 @@ case18 = expected @=? testStep -------------------------------------------------------------------------------- case19 :: Assertion case19 = expected @=? testStep - (step 40 $ Options Global NewLine InlineWithBreak RightAfter (LPConstant 17) True) case19input + (step 40 $ Options Global NewLine InlineWithBreak RightAfter (LPConstant 17) True False) case19input where expected = unlines ---------------------------------------- @@ -465,7 +467,7 @@ case19 = expected @=? testStep case19b :: Assertion case19b = expected @=? testStep - (step 40 $ Options File NewLine InlineWithBreak RightAfter (LPConstant 17) True) case19input + (step 40 $ Options File NewLine InlineWithBreak RightAfter (LPConstant 17) True False) case19input where expected = unlines ---------------------------------------- @@ -480,7 +482,7 @@ case19b = expected @=? testStep case19c :: Assertion case19c = expected @=? testStep - (step 40 $ Options File NewLine InlineWithBreak RightAfter LPModuleName True) case19input + (step 40 $ Options File NewLine InlineWithBreak RightAfter LPModuleName True False) case19input where expected = unlines ---------------------------------------- @@ -495,7 +497,7 @@ case19c = expected @=? testStep case19d :: Assertion case19d = expected @=? testStep - (step 40 $ Options Global NewLine InlineWithBreak RightAfter LPModuleName True) case19input + (step 40 $ Options Global NewLine InlineWithBreak RightAfter LPModuleName True False) case19input where expected = unlines ---------------------------------------- @@ -589,3 +591,50 @@ case22 = expected , "import \"foo\" B (someLongName, someLongerName, " ++ "theLongestNameYet, shortName)" ] + +-------------------------------------------------------------------------------- +case23 :: Assertion +case23 = expected + @=? testStep (step 40 $ Options None AfterAlias Inline Inherit (LPConstant 4) True True) input' + where + expected = unlines + [ "import Data.Acid ( AcidState )" + , "import Data.Default.Class ( Default (def) )" + , "" + , "import Data.Monoid ( (<>) )" + , "" + , "import Data.ALongName.Foo ( Boo, Foo," + , " Goo )" + ] + + input' = unlines + [ "import Data.Acid (AcidState)" + , "import Data.Default.Class (Default(def))" + , "" + , "import Data.Monoid ((<>) )" + , "" + , "import Data.ALongName.Foo (Foo, Goo, Boo)" + ] + +-------------------------------------------------------------------------------- +case24 :: Assertion +case24 = expected + @=? testStep (step 40 $ Options None AfterAlias InlineWithBreak Inherit (LPConstant 4) True True) input' + where + expected = unlines + [ "import Data.Acid ( AcidState )" + , "import Data.Default.Class" + , " ( Default (def) )" + , "" + , "import Data.ALongName.Foo" + , " ( BooReallyLong, FooReallyLong," + , " GooReallyLong )" + ] + + input' = unlines + [ "import Data.Acid (AcidState)" + , "import Data.Default.Class (Default(def))" + , "" + , "import Data.ALongName.Foo (FooReallyLong, " ++ + "GooReallyLong, BooReallyLong)" + ] -- cgit v1.2.3