1
1
{-# LANGUAGE OverloadedStrings #-}
2
2
3
3
import Data.Attoparsec.Text
4
- import qualified Data.Text as T
5
4
import Data.Text (Text )
6
5
import qualified Data.Text.IO as T
7
6
import Hie.Cabal.Parser
@@ -14,89 +13,89 @@ main = hspec spec
14
13
15
14
spec :: Spec
16
15
spec = do
17
- describe " Should Succeed"
18
- $ it " successfully parses executable section"
19
- $ exeSection ~> parseExe 0
20
- `shouldParse` [Comp Exe " gen-hie" " app/Main.hs" ]
21
- describe " Should Succeed"
22
- $ it " successfully parses test section"
23
- $ testSection ~> parseTestSuite 0
24
- `shouldParse` [Comp Test " implicit-hie-test" " test" ]
25
- describe " Should Succeed"
26
- $ it " successfully parses library section"
27
- $ libSection ~> parseLib 0
28
- `shouldParse` [Comp Lib " " " src" ]
29
- describe " Should Succeed"
30
- $ it " successfully parses library section with 2 hs-source-dirs"
31
- $ libSection2 ~> parseLib 0
32
- `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
33
- describe " Should Succeed"
34
- $ it " successfully parses library section with 2 paths under hs-source-dirs"
35
- $ libSection3 ~> parseLib 0
36
- `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
37
- describe " Should Succeed"
38
- $ it " successfully parses bench section"
39
- $ do
40
- bs <- T. readFile " test/benchSection"
41
- bs ~> parseBench 0
42
- `shouldParse` [Comp Bench " folds" " benchmarks/folds.hs" ]
43
- describe " Should Succeed"
44
- $ it " successfully parses package"
45
- $ do
46
- cf <- T. readFile " implicit-hie.cabal"
47
- cf ~> parsePackage
48
- `shouldParse` Package
49
- " implicit-hie"
50
- [ Comp Lib " " " src" ,
51
- Comp Exe " gen-hie" " app/Main.hs" ,
52
- Comp Test " implicit-hie-test" " test"
53
- ]
54
- describe " Should Succeed"
55
- $ it
16
+ describe " Should Succeed" $
17
+ it " successfully parses executable section" $
18
+ exeSection ~> parseExe 0
19
+ `shouldParse` [Comp Exe " gen-hie" " app/Main.hs" ]
20
+ describe " Should Succeed" $
21
+ it " successfully parses test section" $
22
+ testSection ~> parseTestSuite 0
23
+ `shouldParse` [Comp Test " implicit-hie-test" " test" ]
24
+ describe " Should Succeed" $
25
+ it " successfully parses library section" $
26
+ libSection ~> parseLib 0
27
+ `shouldParse` [Comp Lib " " " src" ]
28
+ describe " Should Succeed" $
29
+ it " successfully parses library section with 2 hs-source-dirs" $
30
+ libSection2 ~> parseLib 0
31
+ `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
32
+ describe " Should Succeed" $
33
+ it " successfully parses library section with 2 paths under hs-source-dirs" $
34
+ libSection3 ~> parseLib 0
35
+ `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
36
+ describe " Should Succeed" $
37
+ it " successfully parses bench section" $
38
+ do
39
+ bs <- T. readFile " test/benchSection"
40
+ bs ~> parseBench 0
41
+ `shouldParse` [Comp Bench " folds" " benchmarks/folds.hs" ]
42
+ describe " Should Succeed" $
43
+ it " successfully parses package" $
44
+ do
45
+ cf <- T. readFile " implicit-hie.cabal"
46
+ cf ~> parsePackage
47
+ `shouldParse` Package
48
+ " implicit-hie"
49
+ [ Comp Lib " " " src" ,
50
+ Comp Exe " gen-hie" " app/Main.hs" ,
51
+ Comp Test " implicit-hie-test" " test"
52
+ ]
53
+ describe " Should Succeed" $
54
+ it
56
55
" skips to end of block section"
57
- $ let r = " test\n "
58
- in (libSection <> r) ~?> parseLib 0
59
- `leavesUnconsumed` r
60
- describe " Should Succeed"
61
- $ it " successfully generates stack hie.yaml"
62
- $ do
63
- sf <- readFile " test/stackHie.yaml"
64
- cf <- T. readFile " implicit-hie.cabal"
65
- (hieYaml " stack" . fmtPkgs " stack" . (: [] ) <$> parseOnly parsePackage cf)
66
- `shouldBe` Right sf
67
- describe " Should Succeed"
68
- $ it " successfully generates cabal hie.yaml for haskell-language-server"
69
- $ do
70
- f <- T. readFile " test/haskell-language-server-cabal"
71
- o <- readFile " test/hie.yaml.cbl"
72
- (hieYaml " cabal" . fmtPkgs " cabal" . (: [] ) <$> parseOnly parsePackage f)
73
- `shouldBe` Right o
74
- describe " Should Succeed"
75
- $ it " successfully parses comma list"
76
- $ (" one, two" :: Text ) ~> parseList 1 `shouldParse` [" one" , " two" ]
77
- describe " Should Succeed"
78
- $ it " successfully parses newline list"
79
- $ (" one\n two \n three3" :: Text ) ~> parseList 1
80
- `shouldParse` [" one" , " two" , " three3" ]
81
- describe " Should Succeed"
82
- $ it " successfully parses newline comma list"
83
- $ (" one\n two, three3" :: Text ) ~> parseList 1
84
- `shouldParse` [" one" , " two" , " three3" ]
85
- describe " Should Succeed"
86
- $ it " quoted list"
87
- $ (" \" one\"\n two\n three3" :: Text ) ~> parseList 1
88
- `shouldParse` [" one" , " two" , " three3" ]
89
- describe " Should Succeed"
90
- $ it " list with leading commas"
91
- $ (" one\n , two\n , three3" :: Text ) ~> parseList 1
92
- `shouldParse` [" one" , " two" , " three3" ]
93
- describe " Should Succeed"
94
- $ it " succesfully parses exe component with other-modules containing dots"
95
- $ exeSection2 ~> parseExe 0
96
- `shouldParse` [ Comp Exe " gen-hie" " app/Main.hs"
97
- , Comp Exe " gen-hie" " app/Hie/Executable/Helper.hs"
98
- , Comp Exe " gen-hie" " app/Hie/Executable/Utils.hs"
99
- ]
56
+ $ let r = " test\n "
57
+ in (libSection <> r) ~?> parseLib 0
58
+ `leavesUnconsumed` r
59
+ describe " Should Succeed" $
60
+ it " successfully generates stack hie.yaml" $
61
+ do
62
+ sf <- readFile " test/stackHie.yaml"
63
+ cf <- T. readFile " implicit-hie.cabal"
64
+ (hieYaml " stack" . fmtPkgs " stack" . (: [] ) <$> parseOnly parsePackage cf)
65
+ `shouldBe` Right sf
66
+ describe " Should Succeed" $
67
+ it " successfully generates cabal hie.yaml for haskell-language-server" $
68
+ do
69
+ f <- T. readFile " test/haskell-language-server-cabal"
70
+ o <- readFile " test/hie.yaml.cbl"
71
+ (hieYaml " cabal" . fmtPkgs " cabal" . (: [] ) <$> parseOnly parsePackage f)
72
+ `shouldBe` Right o
73
+ describe " Should Succeed" $
74
+ it " successfully parses comma list" $
75
+ (" one, two" :: Text ) ~> parseList 1 `shouldParse` [" one" , " two" ]
76
+ describe " Should Succeed" $
77
+ it " successfully parses newline list" $
78
+ (" one\n two \n three3" :: Text ) ~> parseList 1
79
+ `shouldParse` [" one" , " two" , " three3" ]
80
+ describe " Should Succeed" $
81
+ it " successfully parses newline comma list" $
82
+ (" one\n two, three3" :: Text ) ~> parseList 1
83
+ `shouldParse` [" one" , " two" , " three3" ]
84
+ describe " Should Succeed" $
85
+ it " quoted list" $
86
+ (" \" one\"\n two\n three3" :: Text ) ~> parseList 1
87
+ `shouldParse` [" one" , " two" , " three3" ]
88
+ describe " Should Succeed" $
89
+ it " list with leading commas" $
90
+ (" one\n , two\n , three3" :: Text ) ~> parseList 1
91
+ `shouldParse` [" one" , " two" , " three3" ]
92
+ describe " Should Succeed" $
93
+ it " succesfully parses exe component with other-modules containing dots" $
94
+ exeSection2 ~> parseExe 0
95
+ `shouldParse` [ Comp Exe " gen-hie" " app/Main.hs" ,
96
+ Comp Exe " gen-hie" " app/Hie/Executable/Helper.hs" ,
97
+ Comp Exe " gen-hie" " app/Hie/Executable/Utils.hs"
98
+ ]
100
99
101
100
exeSection :: Text
102
101
exeSection =
@@ -191,4 +190,4 @@ exeSection2 =
191
190
\ Hie.Executable.Utils\n \
192
191
\ hs-source-dirs:\n \
193
192
\ app\n \
194
- \ main-is: Main.hs \n "
193
+ \ main-is: Main.hs \n "
0 commit comments