@@ -6,7 +6,6 @@ module Parser
6
6
) where
7
7
8
8
import Foundation
9
- import Foundation.String
10
9
import Foundation.Parser
11
10
12
11
import Test.Tasty
@@ -23,7 +22,7 @@ parseTestCase :: (Show a, Eq a)
23
22
-> Parser String a
24
23
-> TestCaseRes a
25
24
-> Assertion
26
- parseTestCase buff parser res = check (parse parser buff) res
25
+ parseTestCase buff parser = check (parse parser buff)
27
26
check :: (Show a , Eq a ) => Result String a -> TestCaseRes a -> Assertion
28
27
check r e = case (r, e) of
29
28
(ParseOK remain a, TestCaseOk eRemain ea) -> do
@@ -71,7 +70,7 @@ parseTestCases = testGroup "units"
71
70
, testCase " MoreFail" $ parseTestCase " aa" (takeWhile (' ' /= )) $ TestCaseMore Nothing TestCaseFail
72
71
]
73
72
, testGroup " takeAll"
74
- [ testCase " OK" $ parseTestCase " abc" ( takeAll) (TestCaseMore Nothing $ TestCaseOk " " " abc" )
73
+ [ testCase " OK" $ parseTestCase " abc" takeAll (TestCaseMore Nothing $ TestCaseOk " " " abc" )
75
74
]
76
75
, testGroup " skip"
77
76
[ testCase " OK" $ parseTestCase " a" (skip 1 ) (TestCaseOk " " () )
@@ -86,7 +85,16 @@ parseTestCases = testGroup "units"
86
85
, testCase " MoreFail" $ parseTestCase " aa" (skipWhile (' ' /= )) $ TestCaseMore Nothing TestCaseFail
87
86
]
88
87
, testGroup " skipAll"
89
- [ testCase " OK" $ parseTestCase " abc" (skipAll) (TestCaseMore Nothing $ TestCaseOk " abc" () )
88
+ [ testCase " OK" $ parseTestCase " abc" skipAll (TestCaseMore Nothing $ TestCaseOk " abc" () )
89
+ ]
90
+ , testGroup " optional"
91
+ [ testCase " Nothing" $ parseTestCase " aaa" (optional $ elements " bbb" ) (TestCaseOk " aaa" Nothing )
92
+ , testCase " Just" $ parseTestCase " aaa" (optional $ elements " a" ) (TestCaseOk " aa" (Just () ))
93
+ ]
94
+ , testGroup " many"
95
+ [ testCase " many elements" $ parseTestCase " 101010\0"
96
+ (many ((element ' 1' >> pure True ) <|> (element ' 0' >> pure False ) ) )
97
+ (TestCaseOk " \0" [True , False , True , False , True , False ])
90
98
]
91
99
]
92
100
0 commit comments