git.iko.soy/typeable/attoparsec
on master help sign in
Add test for scan
commit78803378f0500973b8b6b6e514abd2df5e0201c6 authorJohan Tibell <johan.tibell@gmail.com> dateMon 19 Nov 2012, 20:37 (14 years ago) parent8a0065b
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 ]