@@ -15,6 +15,7 @@ import Text.RawString.QQ
15
15
import Text.Trifecta
16
16
17
17
18
+ -- Example string to test our header parser
18
19
headerEx :: String
19
20
headerEx = " [blah]"
20
21
@@ -27,6 +28,7 @@ parseBracketPair p = char '[' *> p <* char ']'
27
28
parseHeader :: Parser Header
28
29
parseHeader = parseBracketPair (Header <$> some letter)
29
30
31
+ -- Example string to test our assignment parser
30
32
assignmentEx :: String
31
33
assignmentEx = " name=person"
32
34
@@ -45,9 +47,11 @@ parseAssignment = do
45
47
skipEOL
46
48
return (name, value)
47
49
50
+ -- Example string to test our comment parser
48
51
commentEx :: String
49
52
commentEx = " ; comment on ini files looks like this"
50
53
54
+ -- Example string to test our assignment parser
51
55
commentEx' :: String
52
56
commentEx' = " ; also; like this;"
53
57
@@ -59,13 +63,15 @@ skipComments =
59
63
skipEOL
60
64
)
61
65
66
+ -- Example string to test our section parser
62
67
sectionEx :: String
63
68
sectionEx = [r |
64
69
; ignore me
65
70
[states]
66
71
donut=happy
67
72
|]
68
73
74
+ -- A slightly more complex section example. Stress that section.
69
75
sectionEx' :: String
70
76
sectionEx' = [r |
71
77
; example 2
@@ -110,6 +116,12 @@ maybeSuccess :: Result a -> Maybe a
110
116
maybeSuccess (Success a) = Just a
111
117
maybeSuccess _ = Nothing
112
118
119
+ -- We can go ahead and test all the above parsers in ghci/repl
120
+ -- with the given example strings or any other strings which constitutes a valid
121
+ -- ini file
122
+ -- But we can also test the whole thing by writing tests using the example strings
123
+ -- The tests, of course, are also persistent and can be run later to verify a
124
+ -- refactoring or other changes
113
125
main :: IO ()
114
126
main = hspec $ do
115
127
describe " Assignment pairings" $
0 commit comments