blob: 77a23b19a9632ae27d74d16da465394960592bde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
module Language.Haskell.StylishSpec where
--------------------------------------------------------------------------------
import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, (@?=))
--------------------------------------------------------------------------------
import Language.Haskell.Stylish
--------------------------------------------------------------------------------
import System.IO.Unsafe
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Language.Haskell.Stylish.Step.Tabs.Tests"
[ testCase "case 01" case01
, testCase "case 02" case02
, testCase "case 03" case03
]
--------------------------------------------------------------------------------
case01 :: Assertion
case01 = (@?=) result (unsafePerformIO $ format Nothing Nothing input)
where
input = "module Herp where\n data Foo = Bar | Baz"
result = Right [ "module Herp where"
, "data Foo = Bar"
, " | Baz"
]
case02 :: Assertion
case02 = (@?=) result (unsafePerformIO $ format (Just configLocation) Nothing input)
where
configLocation = ConfigPath "testdata/test-config.yaml"
input = "module Herp where\n data Foo = Bar | Baz"
result = Right [ "module Herp where"
, "data Foo = Bar"
, " | Baz"
]
case03 :: Assertion
case03 = do
actual <- format Nothing (Just fileLocation) input
actual @?= result
where
fileLocation = "directory/File.hs"
input = "module Herp"
result = Left $
"Language.Haskell.Stylish.Parse.parseModule: could not parse " <>
fileLocation <>
": ParseFailed (SrcLoc \"<unknown>.hs\" 2 1) \"Parse error: EOF\""
|