Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit b54e1e6

Browse files
committed
Added test case for hsImport.
Elements at indexes 2 and 3 should not format due to GHC bug
1 parent 500e2ea commit b54e1e6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/functional/FunctionalCodeActionsSpec.hs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,48 @@ spec = describe "code actions" $ do
218218
, " $ fromMaybe \"Good night, World!\" (Just \"Hello, World!\")"
219219
]
220220
]
221+
describe "formats with ormolu" $ hsImportSpec "ormolu"
222+
[ -- Expected output for simple format.
223+
[ "import Control.Monad"
224+
, "import qualified Data.Maybe"
225+
, "main :: IO ()"
226+
, "main = when True $ putStrLn \"hello\""
227+
]
228+
, -- Use an import list and format the output.
229+
[ "import Control.Monad (when)"
230+
, "import qualified Data.Maybe"
231+
, "main :: IO ()"
232+
, "main = when True $ putStrLn \"hello\""
233+
]
234+
, -- Multiple import lists, should not introduce multiple newlines.
235+
-- WIP (Haddock issues) ;TODO
236+
[ "import System.IO (hPutStrLn, stdout)"
237+
, "import Control.Monad (when)"
238+
, "import Data.Maybe (fromMaybe)"
239+
, "-- | Main entry point to the program"
240+
, "main :: IO ()"
241+
, "main ="
242+
, " when True"
243+
, " $ hPutStrLn stdout"
244+
, " $ fromMaybe \"Good night, World!\" (Just \"Hello, World!\")"
245+
]
246+
, -- Complex imports for Constructos and functions
247+
-- WIP (Haddock issues) ;TODO
248+
[ "{-# LANGUAGE NoImplicitPrelude #-}"
249+
, "import System.IO (IO, hPutStrLn, stderr)"
250+
, "import Prelude (Bool (..))"
251+
, "import Control.Monad (when)"
252+
, "import Data.Function (($))"
253+
, "import Data.Maybe (Maybe (Just), fromMaybe)"
254+
, "-- | Main entry point to the program"
255+
, "main :: IO ()"
256+
, "main ="
257+
, " when True"
258+
, " $ hPutStrLn stderr"
259+
, " $ fromMaybe \"Good night, World!\" (Just \"Hello, World!\")"
260+
]
261+
]
262+
221263
describe "add package suggestions" $ do
222264
it "adds to .cabal files" $ do
223265
flushStackEnvironment

0 commit comments

Comments
 (0)