Skip to content

Commit b254c6f

Browse files
committed
Add test for fourmolu
1 parent fb8b819 commit b254c6f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/functional/Format.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ tests = testGroup "format document" [
3030
, stylishHaskellTests
3131
, brittanyTests
3232
, ormoluTests
33+
, fourmoluTests
3334
]
3435

3536
rangeTests :: TestTree
@@ -127,6 +128,17 @@ ormoluTests = testGroup "ormolu" [
127128
GHC86 -> "formatted"
128129
_ -> "unchanged"
129130

131+
fourmoluTests :: TestTree
132+
fourmoluTests = testGroup "fourmolu" [
133+
goldenVsStringDiff "formats correctly" goldenGitDiff ("test/testdata/Format.fourmolu.hs") $ runSession hieCommand fullCaps "test/testdata" $ do
134+
let formatLspConfig provider =
135+
object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ]
136+
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu"))
137+
doc <- openDoc "Format.hs" "haskell"
138+
formatDoc doc (FormattingOptions 4 True)
139+
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
140+
]
141+
130142

131143
formatLspConfig :: Value -> Value
132144
formatLspConfig provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ]

test/testdata/Format.fourmolu.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Format where
2+
3+
foo :: Int -> Int
4+
foo 3 = 2
5+
foo x = x
6+
bar :: String -> IO String
7+
bar s = do
8+
x <- return "hello"
9+
return "asdf"
10+
11+
data Baz = Baz {a :: Int, b :: String}
12+

0 commit comments

Comments
 (0)