@@ -66,6 +66,8 @@ module Streamly.Test.Prelude.Common
66 , zipMonadic
66 , zipMonadic
67 , zipAsyncApplicative
67 , zipAsyncApplicative
68 , zipAsyncMonadic
68 , zipAsyncMonadic
69+ -- * Exception operations
69 -- * MonadThrow operations
71 -- * MonadThrow operations
70 , composeWithMonadThrow
72 , composeWithMonadThrow
71 -- * Cleanup tests
73 -- * Cleanup tests
@@ -1372,6 +1374,33 @@ parallelCheck t f = do
1373 where event n = S.yieldM (threadDelay (n * 200000)) >> return n
1375 where event n = S.yieldM (threadDelay (n * 200000)) >> return n
1377+-------------------------------------------------------------------------------
1379+-------------------------------------------------------------------------------
1381+exceptionOps :: IsStream t => String -> (t IO Int -> SerialT IO Int) -> Spec
1382+exceptionOps desc t = do
1383+ prop (desc <> " before") $ beforeProp t
1384+ prop (desc <> " after") $ afterProp t
1386+beforeProp :: IsStream t => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1387+beforeProp t vec = withMaxSuccess maxTestCount $
1389+ ioRef <- run $ newIORef False
1390+ strm <- run $ S.toList . t $ S.before (writeIORef ioRef True) (S.fromList vec)
1391+ refValue <- run $ readIORef ioRef
1393+ assert $ sort strm == sort vec
1395+afterProp :: IsStream t => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1396+afterProp t vec = withMaxSuccess maxTestCount $
1398+ ioRef <- run $ newIORef False
1399+ strm <- run $ S.toList . t $ S.after (writeIORef ioRef True) (S.fromList vec)
1400+ refValue <- run $ readIORef ioRef
1402+ assert $ sort strm == sort vec
1375-------------------------------------------------------------------------------
1404-------------------------------------------------------------------------------
1376-- Compose with MonadThrow
1405-- Compose with MonadThrow
1377-------------------------------------------------------------------------------
1406-------------------------------------------------------------------------------