on master help sign in
Add a test for wAsync behavior check
commit4d4732577d70b82e5147ea4eda41235786a27856 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateThu 3 Feb 2022, 20:38 (5 years ago) parentec20f5f
2 files changed+18
test/Streamly/Test/Prelude/WAsync.hs+5 test/lib/Streamly/Test/Prelude/Common.hs+13
test/Streamly/Test/Prelude/WAsync.hs+5
@@ -47,6 +47,11 @@ main = hspec
4747 wAsyncOps $ prop "wAsyncly consM" . constructWithConsM S.consM sort
4848 wAsyncOps $ prop "wAsyncly (.:)" . constructWithCons (S..:)
4949 wAsyncOps $ prop "wAsyncly (|:)" . constructWithConsM (S.|:) sort
50+ prop "wAsync" $
51+ constructfromWAsync
52+ (S.fromList [1,2,3])
53+ (S.fromList [4,5,6])
54+ [1,4,2,5,3,6]
5055
5156 describe "Functor operations" $ do
5257 wAsyncOps $ functorOps S.fromFoldable "wAsyncly" sortEq
test/lib/Streamly/Test/Prelude/Common.hs+13
@@ -31,6 +31,7 @@ module Streamly.Test.Prelude.Common
3131 , constructWithConsM
3232 , constructWithFromPure
3333 , constructWithFromEffect
34+ , constructfromWAsync
3435 , simpleOps
3536 -- * Applicative operations
3637 , applicativeOps
@@ -290,6 +291,18 @@ constructWithFromIndicesM op len =
290291 streamEffect <- run $ readIORef mvl
291292 listEquals (==) streamEffect list
292293
294+constructfromWAsync ::
295+ S.WAsyncT IO Int -> S.WAsyncT IO Int-> [Int] -> Property
296+constructfromWAsync s1 s2 res =
297+ withMaxSuccess maxTestCount $
298+ monadicIO $ do
299+ x <- run
300+ $ S.toList
301+ $ S.fromWAsync
302+ $ S.maxThreads 1
303+ $ s1 `S.wAsync` s2
304+ equals (==) x res
305+
293306constructWithCons ::
294307 IsStream t
295308 => (Int -> t IO Int -> t IO Int)