|
1 | 1 | {-# LANGUAGE OverloadedStrings #-} |
2 | | -module Main(main) where |
| 2 | +module Main |
| 3 | + ( main |
| 4 | + ) where |
3 | 5 |
|
4 | | -import qualified Data.ByteString.Lazy as BS |
5 | | -import qualified Data.Text.Encoding as T |
6 | | -import qualified Data.Text.IO as T |
7 | | -import qualified Ide.Plugin.Brittany as Brittany |
| 6 | +import qualified Ide.Plugin.Brittany as Brittany |
| 7 | +import System.FilePath |
8 | 8 | import Test.Hls |
9 | 9 |
|
10 | 10 | main :: IO () |
11 | 11 | main = defaultTestRunner tests |
12 | 12 |
|
13 | | -plugin :: PluginDescriptor IdeState |
14 | | -plugin = Brittany.descriptor "brittany" |
| 13 | +brittanyPlugin :: PluginDescriptor IdeState |
| 14 | +brittanyPlugin = Brittany.descriptor "brittany" |
15 | 15 |
|
16 | 16 | tests :: TestTree |
17 | | -tests = testGroup "brittany" [ |
18 | | - goldenGitDiff "formats a document with LF endings" "test/testdata/BrittanyLF.formatted_document.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do |
19 | | - doc <- openDoc "BrittanyLF.hs" "haskell" |
20 | | - formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) |
21 | | - BS.fromStrict . T.encodeUtf8 <$> documentContents doc |
22 | | - |
23 | | - , goldenGitDiff "formats a document with CRLF endings" "test/testdata/BrittanyCRLF.formatted_document.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do |
24 | | - doc <- openDoc "BrittanyCRLF.hs" "haskell" |
25 | | - formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) |
26 | | - BS.fromStrict . T.encodeUtf8 <$> documentContents doc |
27 | | - |
28 | | - , goldenGitDiff "formats a range with LF endings" "test/testdata/BrittanyLF.formatted_range.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do |
29 | | - doc <- openDoc "BrittanyLF.hs" "haskell" |
30 | | - let range = Range (Position 1 0) (Position 2 22) |
31 | | - formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range |
32 | | - BS.fromStrict . T.encodeUtf8 <$> documentContents doc |
33 | | - |
34 | | - , goldenGitDiff "formats a range with CRLF endings" "test/testdata/BrittanyCRLF.formatted_range.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do |
35 | | - doc <- openDoc "BrittanyCRLF.hs" "haskell" |
36 | | - let range = Range (Position 1 0) (Position 2 22) |
37 | | - formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range |
38 | | - BS.fromStrict . T.encodeUtf8 <$> documentContents doc |
39 | | - ] |
| 17 | +tests = testGroup "brittany" |
| 18 | + [ brittanyGolden "formats a document with LF endings" "BrittanyLF" "formatted_document" $ \doc -> do |
| 19 | + formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) |
| 20 | + |
| 21 | + , brittanyGolden "formats a document with CRLF endings" "BrittanyCRLF" "formatted_document" $ \doc -> do |
| 22 | + formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) |
| 23 | + |
| 24 | + , brittanyGolden "formats a range with LF endings" "BrittanyLF" "formatted_range" $ \doc -> do |
| 25 | + let range = Range (Position 1 0) (Position 2 22) |
| 26 | + formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range |
| 27 | + |
| 28 | + , brittanyGolden "formats a range with CRLF endings" "BrittanyCRLF" "formatted_range" $ \doc -> do |
| 29 | + let range = Range (Position 1 0) (Position 2 22) |
| 30 | + formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range |
| 31 | + ] |
| 32 | + |
| 33 | +brittanyGolden :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree |
| 34 | +brittanyGolden title path desc = goldenWithHaskellDocFormatter brittanyPlugin "brittany" title testDataDir path desc "hs" |
| 35 | + |
| 36 | +testDataDir :: FilePath |
| 37 | +testDataDir = "test" </> "testdata" |
0 commit comments