on master help sign in
Increase test coverage a little
commit420d46b4289a8802c82e75828e701e7111d35a7b authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 23 Jun 2011, 10:28 (15 years ago) parent575baec
1 file changed+19−8
tests/tests/src/Data/Text/Tests/Properties.hs+19−8
tests/tests/src/Data/Text/Tests/Properties.hs+19−8
@@ -181,6 +181,8 @@ s_map_s f = map f `eqP` (unpackS . S.unstream . S.map f)
181181sf_map p f = (map f . L.filter p) `eqP` (unpackS . S.map f . S.filter p)
182182t_map f = map f `eqP` (unpackS . T.map f)
183183tl_map f = map f `eqP` (unpackS . TL.map f)
184+s_intercalate c = L.intercalate c `eq`
185+ (unpackS . S.intercalate (packS c) . map packS)
184186t_intercalate c = L.intercalate c `eq`
185187 (unpackS . T.intercalate (packS c) . map packS)
186188tl_intercalate c = L.intercalate c `eq`
@@ -343,6 +345,9 @@ tl_mapAccumR f z = L.mapAccumR f z `eqP` (second unpackS . TL.mapAccumR f z)
343345
344346replicate n l = concat (L.replicate n l)
345347
348+s_replicate n = replicate m `eq`
349+ (unpackS . S.replicateI (fromIntegral m) . packS)
350+ where m = fromIntegral (n :: Word8)
346351t_replicate n = replicate m `eq` (unpackS . T.replicate m . packS)
347352 where m = fromIntegral (n :: Word8)
348353tl_replicate n = replicate m `eq`
@@ -425,14 +430,18 @@ t_breakOn_id s = squid `eq` (uncurry T.append . T.breakOn s)
425430tl_breakOn_id s = squid `eq` (uncurry TL.append . TL.breakOn s)
426431 where squid t | TL.null s = error "empty"
427432 | otherwise = t
428−t_breakOn_start (NotEmpty s) t = let (_,m) = T.breakOn s t
429− in T.null m || s `T.isPrefixOf` m
430−tl_breakOn_start (NotEmpty s) t = let (_,m) = TL.breakOn s t
431− in TL.null m || s `TL.isPrefixOf` m
432−t_breakOnEnd_end (NotEmpty s) t = let (m,_) = T.breakOnEnd s t
433− in T.null m || s `T.isSuffixOf` m
434−tl_breakOnEnd_end (NotEmpty s) t = let (m,_) = TL.breakOnEnd s t
435− in TL.null m || s `TL.isSuffixOf` m
433+t_breakOn_start (NotEmpty s) t =
434+ let (k,m) = T.breakOn s t
435+ in k `T.isPrefixOf` t && (T.null m || s `T.isPrefixOf` m)
436+tl_breakOn_start (NotEmpty s) t =
437+ let (k,m) = TL.breakOn s t
438+ in k `TL.isPrefixOf` t && TL.null m || s `TL.isPrefixOf` m
439+t_breakOnEnd_end (NotEmpty s) t =
440+ let (m,k) = T.breakOnEnd s t
441+ in k `T.isSuffixOf` t && (T.null m || s `T.isSuffixOf` m)
442+tl_breakOnEnd_end (NotEmpty s) t =
443+ let (m,k) = TL.breakOnEnd s t
444+ in k `TL.isSuffixOf` t && (TL.null m || s `TL.isSuffixOf` m)
436445t_break p = L.break p `eqP` (unpack2 . T.break p)
437446tl_break p = L.break p `eqP` (unpack2 . TL.break p)
438447t_group = L.group `eqP` (map unpackS . T.group)
@@ -799,6 +808,7 @@ tests =
799808 testProperty "sf_map" sf_map,
800809 testProperty "t_map" t_map,
801810 testProperty "tl_map" tl_map,
811+ testProperty "s_intercalate" s_intercalate,
802812 testProperty "t_intercalate" t_intercalate,
803813 testProperty "tl_intercalate" tl_intercalate,
804814 testProperty "s_intersperse" s_intersperse,
@@ -904,6 +914,7 @@ tests =
904914 ],
905915
906916 testGroup "unfolds" [
917+ testProperty "s_replicate" s_replicate,
907918 testProperty "t_replicate" t_replicate,
908919 testProperty "tl_replicate" tl_replicate,
909920 testProperty "t_unfoldr" t_unfoldr,