Source

attoparsec / tests / QC / Text.hs

Diff from to

File tests/QC/Text.hs

 {-# OPTIONS_GHC -fno-warn-orphans #-}
 module QC.Text (tests) where
 
-import Control.Applicative ((<$>))
+import Control.Applicative ((<$>), (<*>))
 import Prelude hiding (takeWhile)
 import Test.Framework.Providers.QuickCheck2 (testProperty)
 import Test.QuickCheck
     where v = L.head bs
           bs = L.pack s
 
+peekChar s
+    | L.null s  = p == Just (Nothing, s)
+    | otherwise = p == Just (Just (L.head s), s)
+  where p = maybeP ((,) <$> P.peekChar <*> P.takeLazyText) s
+
 string s t = maybeP (P.string s') (s `L.append` t) == Just s'
   where s' = toStrict s
 
     testProperty "char" char,
     testProperty "notChar" notChar,
     testProperty "anyChar" anyChar,
+    testProperty "peekChar" peekChar,
     testProperty "string" string,
     testProperty "stringCI" stringCI,
     testProperty "skipWhile" skipWhile,