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

Extend FormatSpec with a data types #1605

Merged
merged 2 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions test/functional/FormatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec = do
describe "ormolu" $ do
let formatLspConfig provider =
object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ]

it "formats correctly" $ runSession hieCommand fullCaps "test/testdata" $ do
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu"))
doc <- openDoc "Format.hs" "haskell"
Expand All @@ -117,7 +117,8 @@ formattedDocTabSize2 =
\bar :: String -> IO String\n\
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\n"
\ return \"asdf\"\n\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedDocTabSize5 :: T.Text
formattedDocTabSize5 =
Expand All @@ -128,7 +129,8 @@ formattedDocTabSize5 =
\bar :: String -> IO String\n\
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\n"
\ return \"asdf\"\n\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedRangeTabSize2 :: T.Text
formattedRangeTabSize2 =
Expand All @@ -140,7 +142,8 @@ formattedRangeTabSize2 =
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\
\ \n"
\\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedRangeTabSize5 :: T.Text
formattedRangeTabSize5 =
Expand All @@ -152,7 +155,8 @@ formattedRangeTabSize5 =
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\
\ \n"
\\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedFloskell :: T.Text
formattedFloskell =
Expand All @@ -166,7 +170,7 @@ formattedFloskell =
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\n\
\"
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedBrittanyPostFloskell :: T.Text
formattedBrittanyPostFloskell =
Expand All @@ -179,7 +183,8 @@ formattedBrittanyPostFloskell =
\bar :: String -> IO String\n\
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\n"
\ return \"asdf\"\n\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"

formattedOrmolu :: T.Text
formattedOrmolu =
Expand All @@ -192,10 +197,11 @@ formattedOrmolu =
\bar :: String -> IO String\n\
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n"

\ return \"asdf\"\n\n\
\data Baz = Baz {a :: Int, b :: String}\n"

unchangedOrmolu :: T.Text
unchangedOrmolu =
unchangedOrmolu =
"module Format where\n\
\foo :: Int -> Int\n\
\foo 3 = 2\n\
Expand All @@ -204,4 +210,5 @@ unchangedOrmolu =
\bar s = do\n\
\ x <- return \"hello\"\n\
\ return \"asdf\"\n\
\ \n"
\\n\
\data Baz = Baz { a :: Int, b :: String }\n\n"
4 changes: 3 additions & 1 deletion test/testdata/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ bar :: String -> IO String
bar s = do
x <- return "hello"
return "asdf"


data Baz = Baz { a :: Int, b :: String }