on master help sign in
Make the splitTimes/split correspondence property more sophisticated.

--HG-- extra : convert_revision : a7847509b54339ba504b1176f8964a9023451e51

commit0436c8450311e3cbc323c893972d9eab88769cca authorBryan O'Sullivan <bos@serpentine.com> dateFri 14 Aug 2009, 06:17 (17 years ago) parent6b80be0
1 file changed+7−1
tests/Properties.hs+7−1
tests/Properties.hs+7−1
@@ -37,6 +37,9 @@ crashy onException p = unsafePerformIO $
3737 let types = e :: SomeException
3838 in trace ("*** Exception: " ++ show e) return onException
3939
40+tracer f a = let r = f a
41+ in trace (show r) r
42+
4043prop_T_pack_unpack = (T.unpack . T.pack) `eq` id
4144prop_TL_pack_unpack = (TL.unpack . TL.pack) `eq` id
4245prop_T_stream_unstream = (S.unstream . S.stream) `eq` id
@@ -300,7 +303,10 @@ prop_TL_tails = L.tails `eqP` (map unpackS . TL.tails)
300303
301304prop_T_split_i t = id `eq` (T.intercalate t . T.split t)
302305prop_T_splitTimes_i k t = id `eq` (T.intercalate t . T.splitTimes k t)
303−prop_T_splitTimes_split t = T.splitTimes maxBound t `eq` T.split t
306+prop_T_splitTimes_split k t = T.splitTimes k t `eq` \u ->
307+ case L.splitAt k (T.split t u) of
308+ (a,[]) -> a
309+ (a,b) -> a ++ [T.intercalate t b]
304310prop_T_splitTimesEnd_i k t = id `eq` (T.intercalate t . T.splitTimesEnd k t)
305311prop_T_splitTimesEnd_split t = T.splitTimesEnd maxBound t `eq` T.split t
306312prop_TL_split_i c = id `eq` (TL.intercalate (TL.singleton c) . TL.split c)