git.iko.soy/typeable/attoparsec
on master help sign in
Tidy up tests a bit.
commit951dc4822e7fc7e9bd59e4d1aab9123618d663c1 authorBryan O'Sullivan <bos@serpentine.com> dateTue 9 Mar 2010, 19:10 (17 years ago) parent39aebf2
1 file changed+13−11
tests/QC.hs+13−11
tests/QC.hs+13−11
@@ -36,54 +36,55 @@ maybeP p s = case P.parse p s `P.feed` B.empty of
3636
3737defP p s = P.parse p s `P.feed` B.empty
3838
39−satisfy (w,s) = maybeP (P.satisfy (<=w)) (B.cons w s) == Just w
39+satisfy w s = maybeP (P.satisfy (<=w)) (B.cons w s) == Just w
4040
41−word8 (w,s) = maybeP (P.word8 w) (B.cons w s) == Just w
41+word8 w s = maybeP (P.word8 w) (B.cons w s) == Just w
4242
4343anyWord8 s = maybeP P.anyWord8 s == if B.null s
4444 then Nothing
4545 else Just (B.head s)
4646
47−notWord8 (w, NonEmpty s) = maybeP (P.notWord8 w) s == if v == w
47+notWord8 w (NonEmpty s) = maybeP (P.notWord8 w) s == if v == w
4848 then Nothing
4949 else Just v
5050 where v = B.head s
5151
5252string s = maybeP (P.string s) s == Just s
5353
54−skipWhile (w,s) =
54+skipWhile w s =
5555 let t = B.dropWhile (<=w) s
5656 in case defP (P.skipWhile (<=w)) s of
5757 P.Done t' () -> t == t'
5858 _ -> False
5959
60−takeCount (Positive k,s) =
60+takeCount (Positive k) s =
6161 case maybeP (P.take k) s of
6262 Nothing -> k > B.length s
6363 Just s' -> k <= B.length s
6464
65−takeWhile (w,s) =
65+takeWhile w s =
6666 let (h,t) = B.span (==w) s
6767 in case defP (P.takeWhile (==w)) s of
6868 P.Done t' h' -> t == t' && h == h'
6969 _ -> False
7070
71−takeWhile1 (w, s) =
71+takeWhile1 w s =
7272 let s' = B.cons w s
7373 (h,t) = B.span (<=w) s'
7474 in case defP (P.takeWhile1 (<=w)) s' of
7575 P.Done t' h' -> t == t' && h == h'
7676 _ -> False
7777
78−takeTill (w, s) =
78+takeTill w s =
7979 let (h,t) = B.break (==w) s
8080 in case defP (P.takeTill (==w)) s of
8181 P.Done t' h' -> t == t' && h == h'
8282 _ -> False
8383
84−ensure n s = case defP (P.ensure n) s of
85− P.Done _ () -> B.length s >= n
86− _ -> B.length s < n
84+ensure n s = case defP (P.ensure m) s of
85+ P.Done _ () -> B.length s >= m
86+ _ -> B.length s < m
87+ where m = (n `mod` 220) - 20
8788
8889takeWhile1_empty = maybeP (P.takeWhile1 undefined) B.empty == Nothing
8990
@@ -111,4 +112,5 @@ tests = [
111112 testProperty "endOfInput" endOfInput,
112113 testProperty "ensure" ensure
113114 ]
115+
114116 ]