@@ -234,12 +234,16 @@ t_reverse_short n = L.reverse `eqP` (unpackS . S.reverse . shorten n . S.stream)
235t_replace s d = (L.intercalate d . splitOn s) `eqP`
235t_replace s d = (L.intercalate d . splitOn s) `eqP`
236 (unpackS . T.replace (T.pack s) (T.pack d))
236 (unpackS . T.replace (T.pack s) (T.pack d))
237+t_replace2 (NotEmpty s0) (NotEmpty d0) (NotEmpty w0) =
238+ T.replace s d w =^= T.replace2 s d w
239+ where s = f s0; d = f d0; w = f w0
237tl_replace s d = (L.intercalate d . splitOn s) `eqP`
241tl_replace s d = (L.intercalate d . splitOn s) `eqP`
238 (unpackS . TL.replace (TL.pack s) (TL.pack d))
242 (unpackS . TL.replace (TL.pack s) (TL.pack d))
240splitOn :: (Eq a) => [a] -> [a] -> [[a]]
244splitOn :: (Eq a) => [a] -> [a] -> [[a]]
241splitOn pat src0
245splitOn pat src0
242− | l == 0 = error "empty"
246+ | l == 0 = error "splitOn: empty"
243 | otherwise = go src0
247 | otherwise = go src0
245 l = length pat
249 l = length pat
@@ -896,6 +900,7 @@ tests =
896 testProperty "tl_reverse" tl_reverse,
900 testProperty "tl_reverse" tl_reverse,
897 testProperty "t_reverse_short" t_reverse_short,
901 testProperty "t_reverse_short" t_reverse_short,
898 testProperty "t_replace" t_replace,
902 testProperty "t_replace" t_replace,
903+ testProperty "t_replace2" t_replace2,
899 testProperty "tl_replace" tl_replace,
904 testProperty "tl_replace" tl_replace,
901 testGroup "case conversion" [
906 testGroup "case conversion" [