@@ -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,38 @@ 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`
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+
71104brittanyTests :: TestTree
72105brittanyTests = testGroup " brittany" [
73106 ignoreTestBecause " Broken" $ testCase " formats a document with LF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
0 commit comments