on master help sign in
Add a test for break.
63659ecBryan O'Sullivan
Data/Text.hs+4−4
@@ -1051,10 +1051,10 @@ filter :: (Char -> Bool) -> Text -> Text
1051filter p t = unstream (S.filter p (stream t))
1051filter p t = unstream (S.filter p (stream t))
1052{-# INLINE filter #-}
1052{-# INLINE filter #-}
1053
1053
1054−-- | /O(n+m)/ Find the first instance of @needle@ in @haystack@. The
1054+-- | /O(n+m)/ Find the first instance of @needle@ (which must be
1055−-- first element of the returned tuple is the prefix of @haystack@
1055+-- non-'null') in @haystack@. The first element of the returned tuple
1056−-- before @needle@ is matched. The second is the remainder of
1056+-- is the prefix of @haystack@ before @needle@ is matched. The second
1057−-- @haystack@, starting with the match.
1057+-- is the remainder of @haystack@, starting with the match.
1058--
1058--
1059-- Examples:
1059-- Examples:
1060--
1060--
tests/Properties.hs+5
@@ -387,6 +387,10 @@ t_splitAt n = L.splitAt n `eqP` (unpack2 . T.splitAt n)
387tl_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt (fromIntegral n))
387tl_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt (fromIntegral n))
388t_spanBy p = L.span p `eqP` (unpack2 . T.spanBy p)
388t_spanBy p = L.span p `eqP` (unpack2 . T.spanBy p)
389tl_spanBy p = L.span p `eqP` (unpack2 . TL.spanBy p)
389tl_spanBy p = L.span p `eqP` (unpack2 . TL.spanBy p)
390+
391+t_break_id s = squid `eq` (uncurry T.append . T.break s)
392+ where squid t | T.null s = error "empty"
393+ | otherwise = t
390t_breakBy p = L.break p `eqP` (unpack2 . T.breakBy p)
394t_breakBy p = L.break p `eqP` (unpack2 . T.breakBy p)
391tl_breakBy p = L.break p `eqP` (unpack2 . TL.breakBy p)
395tl_breakBy p = L.break p `eqP` (unpack2 . TL.breakBy p)
392t_group = L.group `eqP` (map unpackS . T.group)
396t_group = L.group `eqP` (map unpackS . T.group)
@@ -770,6 +774,7 @@ tests = [
770 testProperty "tl_splitAt" tl_splitAt,
774 testProperty "tl_splitAt" tl_splitAt,
771 testProperty "t_spanBy" t_spanBy,
775 testProperty "t_spanBy" t_spanBy,
772 testProperty "tl_spanBy" tl_spanBy,
776 testProperty "tl_spanBy" tl_spanBy,
777+ testProperty "t_break_id" t_break_id,
773 testProperty "t_breakBy" t_breakBy,
778 testProperty "t_breakBy" t_breakBy,
774 testProperty "tl_breakBy" tl_breakBy,
779 testProperty "tl_breakBy" tl_breakBy,
775 testProperty "t_group" t_group,
780 testProperty "t_group" t_group,