Skip to content
Browse files

Add test for scan

  • Loading branch information...
1 parent 8a0065b commit 78803378f0500973b8b6b6e514abd2df5e0201c6 @tibbe tibbe committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 tests/QC/ByteString.hs
View
9 tests/QC/ByteString.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-}
module QC.ByteString (tests) where
@@ -94,6 +94,10 @@ endOfInput s = maybeP P.endOfInput s == if L.null s
then Just ()
else Nothing
+scan s (Positive k) = maybeP p s == (Just $ toStrict $ L.take k s)
+ where p = P.scan k $ \ n _ ->
+ if n > 0 then let !n' = n - 1 in Just n' else Nothing
+
tests = [
testProperty "satisfy" satisfy,
testProperty "word8" word8,
@@ -107,5 +111,6 @@ tests = [
testProperty "takeWhile1" takeWhile1,
testProperty "takeWhile1_empty" takeWhile1_empty,
testProperty "takeTill" takeTill,
- testProperty "endOfInput" endOfInput
+ testProperty "endOfInput" endOfInput,
+ testProperty "scan" scan
]

0 comments on commit 7880337

Please sign in to comment.
Something went wrong with that request. Please try again.