on master help sign in
Add a test for break.

--HG-- extra : convert_revision : ab457e447ae34fda190e6d927ef3aaafa549a2d6

commit63659ec3a9bd5e4fb037ca90acea55f121919781 authorBryan O'Sullivan <bos@serpentine.com> dateTue 6 Oct 2009, 21:51 (17 years ago) parentf8a8c56
2 files changed+9−4
Data/Text.hs+4−4 tests/Properties.hs+5
Data/Text.hs+4−4
@@ -1051,10 +1051,10 @@ filter :: (Char -> Bool) -> Text -> Text
10511051filter p t = unstream (S.filter p (stream t))
10521052{-# INLINE filter #-}
10531053
1054−-- | /O(n+m)/ Find the first instance of @needle@ in @haystack@. The
1055−-- first element of the returned tuple is the prefix of @haystack@
1056−-- before @needle@ is matched. The second is the remainder of
1057−-- @haystack@, starting with the match.
1054+-- | /O(n+m)/ Find the first instance of @needle@ (which must be
1055+-- non-'null') in @haystack@. The first element of the returned tuple
1056+-- is the prefix of @haystack@ before @needle@ is matched. The second
1057+-- is the remainder of @haystack@, starting with the match.
10581058--
10591059-- Examples:
10601060--
tests/Properties.hs+5
@@ -387,6 +387,10 @@ t_splitAt n = L.splitAt n `eqP` (unpack2 . T.splitAt n)
387387tl_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt (fromIntegral n))
388388t_spanBy p = L.span p `eqP` (unpack2 . T.spanBy p)
389389tl_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
390394t_breakBy p = L.break p `eqP` (unpack2 . T.breakBy p)
391395tl_breakBy p = L.break p `eqP` (unpack2 . TL.breakBy p)
392396t_group = L.group `eqP` (map unpackS . T.group)
@@ -770,6 +774,7 @@ tests = [
770774 testProperty "tl_splitAt" tl_splitAt,
771775 testProperty "t_spanBy" t_spanBy,
772776 testProperty "tl_spanBy" tl_spanBy,
777+ testProperty "t_break_id" t_break_id,
773778 testProperty "t_breakBy" t_breakBy,
774779 testProperty "tl_breakBy" tl_breakBy,
775780 testProperty "t_group" t_group,