Skip to content

Commit 6f8c980

Browse files
committed
Add test cases for stylish-haskell
1 parent 1b790db commit 6f8c980

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/functional/Format.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ tests = testGroup "format document" [
2424
documentContents doc >>= liftIO . (`shouldBe` formattedDocTabSize5)
2525
, rangeTests
2626
, providerTests
27+
, stylishHaskellTests
2728
, brittanyTests
2829
, ormoluTests
2930
]
@@ -68,6 +69,16 @@ providerTests = testGroup "formatting provider" [
6869
documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell)
6970
]
7071

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` formattedStylishHaskell
80+
]
81+
7182
brittanyTests :: TestTree
7283
brittanyTests = testGroup "brittany" [
7384
ignoreTestBecause "Broken" $ testCase "formats a document with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
@@ -175,6 +186,18 @@ formattedRangeTabSize5 =
175186
\\n\
176187
\data Baz = Baz { a :: Int, b :: String }\n\n"
177188

189+
formattedStylishHaskell :: T.Text
190+
formattedStylishHaskell =
191+
"import Data.Char\n\
192+
\import qualified Data.List\n\
193+
\import Data.String\n\
194+
\\n\
195+
\bar :: Maybe (Either String Integer) -> Integer\n\
196+
\bar Nothing = 0\n\
197+
\bar (Just (Left _)) = 0\n\
198+
\bar (Just (Right x)) = x\n\
199+
\"
200+
178201
formattedFloskell :: T.Text
179202
formattedFloskell =
180203
"module Format where\n\

test/testdata/StylishHaskell.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Data.Char
2+
import qualified Data.List
3+
import Data.String
4+
5+
bar :: Maybe (Either String Integer) -> Integer
6+
bar Nothing = 0
7+
bar (Just (Left _)) = 0
8+
bar (Just (Right x)) = x

0 commit comments

Comments
 (0)