Commits

Nicolas Pouillard committed 7b892e5

Properties: also tests using small chunks (reveals a bug in splitAt).

Comments (0)

Files changed (1)

tests/Properties.hs

     packT    :: String -> t
     unpackT  :: t -> String
     splitAtT :: Int -> t -> (t,t)
+    packTChunkSize :: Int -> String -> t
+    packTChunkSize _ = packT
 
 instance Target (S.Stream Char) where
     packT        = S.streamList
     splitAtT = T.splitAt
 
 instance Target TL.Text where
+    packTChunkSize k = SL.unstreamChunks k . S.streamList
     packT    = TL.pack
     unpackT  = TL.unpack
     splitAtT = TL.splitAt . fromIntegral
 eqP :: (Eq a, Show a, Target t) =>
        (String -> a) -> (t -> a) -> String -> Word8 -> Bool
 eqP a b s w  = eq "orig" (a s) (b t) &&
+               eq "mini" (a s) (b mini) &&
                eq "head" (a sa) (b ta) &&
                eq "tail" (a sb) (b tb)
     where t             = packT s
+          mini          = packTChunkSize 10 s
           (sa,sb)       = splitAt m s
           (ta,tb)       = splitAtT m t
           l             = length s
 eqEP :: (Eq a, Target t) =>
         (String -> a) -> (t -> a) -> NotEmpty String -> Word8 -> Bool
 eqEP a b e w  = a s == b t &&
+                a s == b mini &&
                 (null sa || a sa == b ta) &&
                 (null sb || a sb == b tb)
     where (sa,sb)       = splitAt m s
           (ta,tb)       = splitAtT m t
           t             = packT s
+          mini          = packTChunkSize 10 s
           l             = length s
           m | l == 0    = n
             | otherwise = n `mod` l