@@ -88,7 +88,7 @@ module Streamly.Test.Prelude.Common
8888import Control.Applicative (ZipList(..), liftA2)
8989import Control.Exception (Exception, try)
9090import Control.Concurrent (threadDelay)
91−import Control.Monad (replicateM)
91+import Control.Monad (replicateM, when)
9292import Control.Monad.Catch (throwM, MonadThrow)
9393import Data.Function ((&))
9494import Data.IORef (IORef, modifyIORef', newIORef, readIORef, writeIORef)
@@ -1433,10 +1433,9 @@ bracketProp t vec =
14331433 refValue <- run $ readIORef ioRef
14341434 assert $ refValue == 1
14351435
1436−-- XXX This test fails
1437−_bracketPartialStreamProp ::
1436+bracketPartialStreamProp ::
14381437 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1439−_bracketPartialStreamProp t vec =
1438+bracketPartialStreamProp t vec =
14401439 forAll (choose (0, length vec)) $ \len -> do
14411440 withMaxSuccess maxTestCount $
14421441 monadicIO $ do
@@ -1445,15 +1444,18 @@ _bracketPartialStreamProp t vec =
14451444 S.drain . t $
14461445 S.take len $
14471446 S.bracket
1448− (return ioRef)
1449− (`writeIORef` 1)
1447+ (writeIORef ioRef 1 >> return ioRef)
1448+ (`writeIORef` 3)
14501449 (\ioref ->
14511450 S.mapM
14521451 (\a -> writeIORef ioref 2 >> return a)
14531452 (S.fromList vec))
1454− run performMajorGC
1453+ run $ do
1454+ performMajorGC
1455+ threadDelay 10000
14551456 refValue <- run $ readIORef ioRef
1456− assert $ refValue == 1
1457+ when (refValue /= 0 && refValue /= 3) $
1458+ error $ "refValue == " ++ show refValue
14571459
14581460bracketExceptionProp ::
14591461 (IsStream t, MonadThrow (t IO)
@@ -1491,10 +1493,9 @@ finallyProp t vec =
14911493 refValue <- run $ readIORef ioRef
14921494 assert $ refValue == 1
14931495
1494−-- XXX This test fails
1495−_finallyPartialStreamProp ::
1496+finallyPartialStreamProp ::
14961497 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1497−_finallyPartialStreamProp t vec =
1498+finallyPartialStreamProp t vec =
14981499 forAll (choose (0, length vec)) $ \len -> do
14991500 withMaxSuccess maxTestCount $
15001501 monadicIO $ do
@@ -1503,13 +1504,16 @@ _finallyPartialStreamProp t vec =
15031504 S.drain . t $
15041505 S.take len $
15051506 S.finally
1506− (writeIORef ioRef 1)
1507+ (writeIORef ioRef 2)
15071508 (S.mapM
1508− (\a -> writeIORef ioRef 2 >> return a)
1509+ (\a -> writeIORef ioRef 1 >> return a)
15091510 (S.fromList vec))
1510− run performMajorGC
1511+ run $ do
1512+ performMajorGC
1513+ threadDelay 10000
15111514 refValue <- run $ readIORef ioRef
1512− assert $ refValue == 1
1515+ when (refValue /= 0 && refValue /= 2) $
1516+ error $ "refValue == " ++ show refValue
15131517
15141518finallyExceptionProp ::
15151519 (IsStream t, MonadThrow (t IO)
@@ -1584,11 +1588,11 @@ exceptionOps desc t = do
15841588 prop (desc <> " before") $ beforeProp t
15851589 prop (desc <> " after") $ afterProp t
15861590 prop (desc <> " bracket end of stream") $ bracketProp t
1587− -- prop (desc <> " bracket partial stream") $ bracketPartialStreamProp t
1591+ prop (desc <> " bracket partial stream") $ bracketPartialStreamProp t
15881592 prop (desc <> " bracket exception in stream") $ bracketExceptionProp t
15891593 prop (desc <> " onException") $ onExceptionProp t
15901594 prop (desc <> " finally end of stream") $ finallyProp t
1591− -- prop (desc <> " finally partial stream") $ finallyPartialStreamProp t
1595+ prop (desc <> " finally partial stream") $ finallyPartialStreamProp t
15921596 prop (desc <> " finally exception in stream") $ finallyExceptionProp t
15931597 prop (desc <> " handle") $ handleProp t
15941598