Commits

Bryan O'Sullivan committed d3631d7

Add a test for break.

Comments (0)

Files changed (2)

 filter p t = unstream (S.filter p (stream t))
 {-# INLINE filter #-}
 
--- | /O(n+m)/ Find the first instance of @needle@ in @haystack@.  The
--- first element of the returned tuple is the prefix of @haystack@
--- before @needle@ is matched.  The second is the remainder of
--- @haystack@, starting with the match.
+-- | /O(n+m)/ Find the first instance of @needle@ (which must be
+-- non-'null') in @haystack@.  The first element of the returned tuple
+-- is the prefix of @haystack@ before @needle@ is matched.  The second
+-- is the remainder of @haystack@, starting with the match.
 --
 -- Examples:
 --

tests/Properties.hs

 tl_splitAt n      = L.splitAt n   `eqP` (unpack2 . TL.splitAt (fromIntegral n))
 t_spanBy p        = L.span p      `eqP` (unpack2 . T.spanBy p)
 tl_spanBy p       = L.span p      `eqP` (unpack2 . TL.spanBy p)
+
+t_break_id s      = squid `eq` (uncurry T.append . T.break s)
+  where squid t | T.null s  = error "empty"
+                | otherwise = t
 t_breakBy p       = L.break p     `eqP` (unpack2 . T.breakBy p)
 tl_breakBy p      = L.break p     `eqP` (unpack2 . TL.breakBy p)
 t_group           = L.group       `eqP` (map unpackS . T.group)
       testProperty "tl_splitAt" tl_splitAt,
       testProperty "t_spanBy" t_spanBy,
       testProperty "tl_spanBy" tl_spanBy,
+      testProperty "t_break_id" t_break_id,
       testProperty "t_breakBy" t_breakBy,
       testProperty "tl_breakBy" tl_breakBy,
       testProperty "t_group" t_group,