on master help sign in
Make the split* functions undefined over empty delimiters as inputs.

--HG-- extra : convert_revision : eae6f04d062bb004a3c5fd6b8048089abbdf8b0a

commitbdb68cb19a8189cba067200aa12feb07784ac2eb authorBryan O'Sullivan <bos@serpentine.com> dateSun 16 Aug 2009, 06:21 (17 years ago) parent114443d
1 file changed+20−18
tests/Properties.hs+20−18
tests/Properties.hs+20−18
@@ -27,7 +27,7 @@ import System.IO.Unsafe (unsafePerformIO)
2727import Test.Framework (defaultMain, testGroup)
2828import Test.Framework.Providers.QuickCheck (testProperty)
2929
30−import QuickCheckUtils ()
30+import QuickCheckUtils (NotEmpty(..))
3131
3232-- Ensure that two potentially bottom values (in the sense of crashing
3333-- for some inputs, not looping infinitely) either both crash, or both
@@ -209,7 +209,7 @@ tl_replace s d = (L.intercalate d . split s) `eqP` (unpackS . TL.replace (TL
209209
210210split :: (Eq a) => [a] -> [a] -> [[a]]
211211split pat src0
212− | l == 0 = [src0]
212+ | l == 0 = error "empty"
213213 | otherwise = go src0
214214 where
215215 l = length pat
@@ -377,22 +377,24 @@ tl_inits = L.inits `eqP` (map unpackS . TL.inits)
377377t_tails = L.tails `eqP` (map unpackS . T.tails)
378378tl_tails = L.tails `eqP` (map unpackS . TL.tails)
379379
380−t_split_i t = id `eq` (T.intercalate t . T.split t)
381−t_splitTimes_i k t = id `eq` (T.intercalate t . T.splitTimes k t)
382−tl_splitTimes_i k t = id `eq` (TL.intercalate t . TL.splitTimes k t)
383−t_splitTimes_split k t = T.splitTimes k t `eq` \u ->
384− case L.splitAt k (T.split t u) of
385− (a,[]) -> a
386− (a,b) -> a ++ [T.intercalate t b]
387−tl_splitTimes_split k t = TL.splitTimes k t `eq` \u ->
388− case L.splitAt (fromIntegral k) (TL.split t u) of
389− (a,[]) -> a
390− (a,b) -> a ++ [TL.intercalate t b]
391−t_splitTimesEnd_i k t = id `eq` (T.intercalate t . T.splitTimesEnd k t)
392−tl_splitTimesEnd_i k t = id `eq` (TL.intercalate t . TL.splitTimesEnd k t)
393−t_splitTimesEnd_split t = T.splitTimesEnd maxBound t `eq` T.split t
394−tl_splitTimesEnd_split t = TL.splitTimesEnd maxBound t `eq` TL.split t
395−tl_split_i t = id `eq` (TL.intercalate t . TL.split t)
380+t_split_i (NotEmpty t) = id `eq` (T.intercalate t . T.split t)
381+tl_split_i (NotEmpty t) = id `eq` (TL.intercalate t . TL.split t)
382+t_splitTimes_i k (NotEmpty t) = id `eq` (T.intercalate t . T.splitTimes k t)
383+tl_splitTimes_i k (NotEmpty t) = id `eq` (TL.intercalate t . TL.splitTimes k t)
384+t_splitTimes_split k (NotEmpty t) =
385+ T.splitTimes k t `eq` \u ->
386+ case L.splitAt k (T.split t u) of
387+ (a,[]) -> a
388+ (a,b) -> a ++ [T.intercalate t b]
389+tl_splitTimes_split k (NotEmpty t) =
390+ TL.splitTimes k t `eq` \u ->
391+ case L.splitAt (fromIntegral k) (TL.split t u) of
392+ (a,[]) -> a
393+ (a,b) -> a ++ [TL.intercalate t b]
394+t_splitTimesEnd_i k (NotEmpty t) = id `eq` (T.intercalate t . T.splitTimesEnd k t)
395+tl_splitTimesEnd_i k (NotEmpty t) = id `eq` (TL.intercalate t . TL.splitTimesEnd k t)
396+t_splitTimesEnd_split (NotEmpty t) = T.splitTimesEnd maxBound t `eq` T.split t
397+tl_splitTimesEnd_split (NotEmpty t) = TL.splitTimesEnd maxBound t `eq` TL.split t
396398
397399t_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
398400t_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.countChar c)