summaryrefslogtreecommitdiffhomepage
path: root/tests/Language/Haskell/Stylish/Step/Squash/Tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Language/Haskell/Stylish/Step/Squash/Tests.hs')
-rw-r--r--tests/Language/Haskell/Stylish/Step/Squash/Tests.hs121
1 files changed, 121 insertions, 0 deletions
diff --git a/tests/Language/Haskell/Stylish/Step/Squash/Tests.hs b/tests/Language/Haskell/Stylish/Step/Squash/Tests.hs
new file mode 100644
index 0000000..a785d9a
--- /dev/null
+++ b/tests/Language/Haskell/Stylish/Step/Squash/Tests.hs
@@ -0,0 +1,121 @@
+--------------------------------------------------------------------------------
+module Language.Haskell.Stylish.Step.Squash.Tests
+ ( tests
+ ) where
+
+
+--------------------------------------------------------------------------------
+import Test.Framework (Test, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
+import Test.HUnit (Assertion, (@=?))
+
+
+--------------------------------------------------------------------------------
+import Language.Haskell.Stylish.Step.Squash
+import Language.Haskell.Stylish.Tests.Util
+
+
+--------------------------------------------------------------------------------
+tests :: Test
+tests = testGroup "Language.Haskell.Stylish.Step.SimpleSquash.Tests"
+ [ testCase "case 01" case01
+ , testCase "case 02" case02
+ , testCase "case 03" case03
+ , testCase "case 04" case04
+ , testCase "case 05" case05
+ ]
+
+
+--------------------------------------------------------------------------------
+case01 :: Assertion
+case01 = expected @=? testStep step input
+ where
+ input = unlines
+ [ "data Foo = Foo"
+ , " { foo :: Int"
+ , " , barqux :: String"
+ , " } deriving (Show)"
+ ]
+
+ expected = unlines
+ [ "data Foo = Foo"
+ , " { foo :: Int"
+ , " , barqux :: String"
+ , " } deriving (Show)"
+ ]
+
+
+--------------------------------------------------------------------------------
+case02 :: Assertion
+case02 = expected @=? testStep step input
+ where
+ input = unlines
+ [ "data Foo = Foo"
+ , " { fooqux"
+ , " , bar :: String"
+ , " } deriving (Show)"
+ ]
+
+ expected = unlines
+ [ "data Foo = Foo"
+ , " { fooqux"
+ , " , bar :: String"
+ , " } deriving (Show)"
+ ]
+
+
+--------------------------------------------------------------------------------
+case03 :: Assertion
+case03 = expected @=? testStep step input
+ where
+ input = unlines
+ [ "maybe y0 f mx ="
+ , " case mx of"
+ , " Nothing -> y0"
+ , " Just x -> f x"
+ ]
+
+ expected = unlines
+ [ "maybe y0 f mx ="
+ , " case mx of"
+ , " Nothing -> y0"
+ , " Just x -> f x"
+ ]
+
+
+--------------------------------------------------------------------------------
+case04 :: Assertion
+case04 = expected @=? testStep step input
+ where
+ input = unlines
+ [ "maybe y0 f mx ="
+ , " case mx of"
+ , " Nothing ->"
+ , " y0"
+ , " Just x ->"
+ , " f x"
+ ]
+
+ expected = unlines
+ [ "maybe y0 f mx ="
+ , " case mx of"
+ , " Nothing ->"
+ , " y0"
+ , " Just x ->"
+ , " f x"
+ ]
+
+
+--------------------------------------------------------------------------------
+case05 :: Assertion
+case05 = expected @=? testStep step input
+ where
+ input = unlines
+ [ "maybe y0 _ Nothing = y"
+ , "maybe _ f (Just x) = f x"
+ ]
+
+ expected = unlines
+ [ "maybe y0 _ Nothing = y"
+ , "maybe _ f (Just x) = f x"
+ ]