@@ -13,11 +13,13 @@ import Data.List (sort)
13#if __GLASGOW_HASKELL__ < 808
13#if __GLASGOW_HASKELL__ < 808
14import Data.Semigroup ((<>))
14import Data.Semigroup ((<>))
16−import Test.QuickCheck (Property)
16+import Test.QuickCheck (Property, forAll)
17import Test.Hspec.QuickCheck
17import Test.Hspec.QuickCheck
18import Test.QuickCheck.Monadic (monadicIO, run)
18import Test.QuickCheck.Monadic (monadicIO, run)
19import Test.Hspec as H
19import Test.Hspec as H
21+import qualified Streamly.Internal.Data.Stream.Serial as Serial
21import Streamly.Prelude hiding (repeat)
23import Streamly.Prelude hiding (repeat)
22import qualified Streamly.Prelude as S
24import qualified Streamly.Prelude as S
@@ -55,6 +57,17 @@ interleaveCheck t f =
55 singleton :: IsStream t => a -> t m a
57 singleton :: IsStream t => a -> t m a
56 singleton a = a .: nil
58 singleton a = a .: nil
60+wSerialMinLengthProp :: Property
61+wSerialMinLengthProp =
62+ forAll (chooseInt (0, 10))
63+ $ \len -> S.length (combined len) `shouldReturn` 2 * len + 1
67+ finiteStream len = S.take len $ S.repeat (1 :: Int)
68+ infiniteStream = S.repeat 1
69+ combined len = infiniteStream `Serial.wSerialMin` finiteStream len
58main :: IO ()
71main :: IO ()
59main = hspec
72main = hspec
60 $ H.parallel
73 $ H.parallel
@@ -158,3 +171,11 @@ main = hspec
159 describe "Tests for exceptions" $ wSerialOps $ exceptionOps "wSerially"
172 describe "Tests for exceptions" $ wSerialOps $ exceptionOps "wSerially"
160 describe "Composed MonadThrow wSerially" $ composeWithMonadThrow wSerially
173 describe "Composed MonadThrow wSerially" $ composeWithMonadThrow wSerially
175+ ---------------------------------------------------------------------------
176+ -- Termination checks
177+ ---------------------------------------------------------------------------
179+ describe "wSerialMin termination" $
180+ prop "len (infinite `wSerialMin` finite) = 2 * len(finite) + 1"
181+ wSerialMinLengthProp