From 4d4732577d70b82e5147ea4eda41235786a27856 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Thu, 3 Feb 2022 20:38:42 +0530 Subject: [PATCH] Add a test for wAsync behavior check --- test/Streamly/Test/Prelude/WAsync.hs | 5 +++++ test/lib/Streamly/Test/Prelude/Common.hs | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/test/Streamly/Test/Prelude/WAsync.hs b/test/Streamly/Test/Prelude/WAsync.hs index aea34ee9..f79f1c59 100644 --- a/test/Streamly/Test/Prelude/WAsync.hs +++ b/test/Streamly/Test/Prelude/WAsync.hs @@ -47,6 +47,11 @@ main = hspec wAsyncOps $ prop "wAsyncly consM" . constructWithConsM S.consM sort wAsyncOps $ prop "wAsyncly (.:)" . constructWithCons (S..:) wAsyncOps $ prop "wAsyncly (|:)" . constructWithConsM (S.|:) sort + prop "wAsync" $ + constructfromWAsync + (S.fromList [1,2,3]) + (S.fromList [4,5,6]) + [1,4,2,5,3,6] describe "Functor operations" $ do wAsyncOps $ functorOps S.fromFoldable "wAsyncly" sortEq diff --git a/test/lib/Streamly/Test/Prelude/Common.hs b/test/lib/Streamly/Test/Prelude/Common.hs index 22594b16..f0973578 100644 --- a/test/lib/Streamly/Test/Prelude/Common.hs +++ b/test/lib/Streamly/Test/Prelude/Common.hs @@ -31,6 +31,7 @@ module Streamly.Test.Prelude.Common , constructWithConsM , constructWithFromPure , constructWithFromEffect + , constructfromWAsync , simpleOps -- * Applicative operations , applicativeOps @@ -290,6 +291,18 @@ constructWithFromIndicesM op len = streamEffect <- run $ readIORef mvl listEquals (==) streamEffect list +constructfromWAsync :: + S.WAsyncT IO Int -> S.WAsyncT IO Int-> [Int] -> Property +constructfromWAsync s1 s2 res = + withMaxSuccess maxTestCount $ + monadicIO $ do + x <- run + $ S.toList + $ S.fromWAsync + $ S.maxThreads 1 + $ s1 `S.wAsync` s2 + equals (==) x res + constructWithCons :: IsStream t => (Int -> t IO Int -> t IO Int)