From 541b0ccd7eb55161a17f91712c0ac985079d54fc Mon Sep 17 00:00:00 2001 From: Pawel Szulc Date: Sun, 26 Jan 2020 12:20:56 +0000 Subject: [PATCH 1/2] Extend FormatSpec with a data types Show how different formatters are formatting code with a data type definition --- test/functional/FormatSpec.hs | 29 ++++++++++++++++++----------- test/testdata/Format.hs | 4 +++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/test/functional/FormatSpec.hs b/test/functional/FormatSpec.hs index bbb8052cd..25533b670 100644 --- a/test/functional/FormatSpec.hs +++ b/test/functional/FormatSpec.hs @@ -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" @@ -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 = @@ -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 = @@ -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 = @@ -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 = @@ -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 = @@ -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 = @@ -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\ @@ -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" diff --git a/test/testdata/Format.hs b/test/testdata/Format.hs index 76e40c981..d4682acaa 100644 --- a/test/testdata/Format.hs +++ b/test/testdata/Format.hs @@ -6,4 +6,6 @@ bar :: String -> IO String bar s = do x <- return "hello" return "asdf" - + +data Baz = Baz { a :: Int, b :: String } + From 6aa69a712816b9312a901de04f949248fd6d0282 Mon Sep 17 00:00:00 2001 From: fendor Date: Thu, 12 Mar 2020 23:08:27 +0100 Subject: [PATCH 2/2] Remove unused spaces --- test/functional/FormatSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/FormatSpec.hs b/test/functional/FormatSpec.hs index 25533b670..6afa5dce3 100644 --- a/test/functional/FormatSpec.hs +++ b/test/functional/FormatSpec.hs @@ -210,5 +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"