git.iko.soy/typeable/attoparsec
on master help sign in
Merge pull request #36 from tibbe/scan

Add test for scan

commitf6f9a4609c3ef430d51171c5361fc2a93177f86a authorBryan O'Sullivan <bos@serpentine.com> dateMon 19 Nov 2012, 21:33 (14 years ago) parent8a0065b7880337
1 file changed+7−2
tests/QC/ByteString.hs+7−2
tests/QC/ByteString.hs+7−2
@@ -1,4 +1,4 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-}
33module QC.ByteString (tests) where
44
@@ -94,6 +94,10 @@ endOfInput s = maybeP P.endOfInput s == if L.null s
9494 then Just ()
9595 else Nothing
9696
97+scan s (Positive k) = maybeP p s == (Just $ toStrict $ L.take k s)
98+ where p = P.scan k $ \ n _ ->
99+ if n > 0 then let !n' = n - 1 in Just n' else Nothing
100+
97101tests = [
98102 testProperty "satisfy" satisfy,
99103 testProperty "word8" word8,
@@ -107,5 +111,6 @@ tests = [
107111 testProperty "takeWhile1" takeWhile1,
108112 testProperty "takeWhile1_empty" takeWhile1_empty,
109113 testProperty "takeTill" takeTill,
110− testProperty "endOfInput" endOfInput
114+ testProperty "endOfInput" endOfInput,
115+ testProperty "scan" scan
111116 ]