diff --git a/test/functional/Format.hs b/test/functional/Format.hs index 4b58b6d793..539f11358b 100644 --- a/test/functional/Format.hs +++ b/test/functional/Format.hs @@ -57,15 +57,20 @@ providerTests = testGroup "formatting provider" [ resp <- request STextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing) liftIO $ resp ^. LSP.result @?= (Left $ ResponseError InvalidRequest "No plugin enabled for STextDocumentFormatting, available: []" Nothing) -#if AGPL + , testCase "respects initial" $ runSessionWithConfig (formatConfig "floskell") hlsCommand fullCaps "test/testdata/format" $ do + doc <- openDoc "Format.hs" "haskell" + formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.initial.hs" + formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) + documentContents doc >>= liftIO . (@?= formattedFloskell) + , testCase "can change on the fly" $ runSession hlsCommand fullCaps "test/testdata/format" $ do - formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.brittany.formatted.hs" + formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.ormolu.formatted.hs" formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs" - formattedBrittanyPostFloskell <- liftIO $ T.readFile "test/testdata/format/Format.brittany_post_floskell.formatted.hs" + formattedBrittanyPostFloskell <- liftIO $ T.readFile "test/testdata/format/Format.ormolu_post_floskell.formatted.hs" doc <- openDoc "Format.hs" "haskell" - sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany")) + sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu")) formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) documentContents doc >>= liftIO . (@?= formattedBrittany) @@ -73,23 +78,22 @@ providerTests = testGroup "formatting provider" [ formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) documentContents doc >>= liftIO . (@?= formattedFloskell) - sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany")) + sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu")) formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) documentContents doc >>= liftIO . (@?= formattedBrittanyPostFloskell) , testCase "supports both new and old configuration sections" $ runSession hlsCommand fullCaps "test/testdata/format" $ do - formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.brittany.formatted.hs" + formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.ormolu.formatted.hs" formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs" doc <- openDoc "Format.hs" "haskell" - sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfigOld "brittany")) + sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfigOld "ormolu")) formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) documentContents doc >>= liftIO . (@?= formattedBrittany) sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfigOld "floskell")) formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) documentContents doc >>= liftIO . (@?= formattedFloskell) -#endif ] stylishHaskellTests :: TestTree diff --git a/test/testdata/format/Format.floskell.formatted.hs b/test/testdata/format/Format.floskell.formatted.hs index ac0b2ebfb6..99879567c0 100644 --- a/test/testdata/format/Format.floskell.formatted.hs +++ b/test/testdata/format/Format.floskell.formatted.hs @@ -1,7 +1,7 @@ module Format where -import Data.List import Data.Int +import Data.List import Prelude foo :: Int -> Int @@ -14,4 +14,3 @@ bar s = do return "asdf" data Baz = Baz { a :: Int, b :: String } -