@@ -24,6 +24,7 @@ tests = testGroup "format document" [
24
24
documentContents doc >>= liftIO . (`shouldBe` formattedDocTabSize5)
25
25
, rangeTests
26
26
, providerTests
27
+ , stylishHaskellTests
27
28
, brittanyTests
28
29
, ormoluTests
29
30
]
@@ -68,6 +69,38 @@ providerTests = testGroup "formatting provider" [
68
69
documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell)
69
70
]
70
71
72
+ stylishHaskellTests :: TestTree
73
+ stylishHaskellTests = testGroup " stylish-haskell" [
74
+ testCase " formats a file" $ runSession hieCommand fullCaps " test/testdata" $ do
75
+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig " stylish-haskell" ))
76
+ doc <- openDoc " StylishHaskell.hs" " haskell"
77
+ formatDoc doc (FormattingOptions 2 True )
78
+ contents <- documentContents doc
79
+ liftIO $ contents `shouldBe`
80
+ " import Data.Char\n \
81
+ \import qualified Data.List\n \
82
+ \import Data.String\n \
83
+ \\n \
84
+ \bar :: Maybe (Either String Integer) -> Integer\n \
85
+ \bar Nothing = 0\n \
86
+ \bar (Just (Left _)) = 0\n \
87
+ \bar (Just (Right x)) = x\n "
88
+ , testCase " formats a range" $ runSession hieCommand fullCaps " test/testdata" $ do
89
+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig " stylish-haskell" ))
90
+ doc <- openDoc " StylishHaskell.hs" " haskell"
91
+ formatRange doc (FormattingOptions 2 True ) (Range (Position 0 0 ) (Position 2 21 ))
92
+ contents <- documentContents doc
93
+ liftIO $ contents `shouldBe`
94
+ " import Data.Char\n \
95
+ \import qualified Data.List\n \
96
+ \import Data.String\n \
97
+ \\n \
98
+ \bar :: Maybe (Either String Integer) -> Integer\n \
99
+ \bar Nothing = 0\n \
100
+ \bar (Just (Left _)) = 0\n \
101
+ \bar (Just (Right x)) = x\n "
102
+ ]
103
+
71
104
brittanyTests :: TestTree
72
105
brittanyTests = testGroup " brittany" [
73
106
ignoreTestBecause " Broken" $ testCase " formats a document with LF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
0 commit comments