on master help sign in
Add a test for wAsync behavior check
4d47325Ranjeet Kumar Ranjan
test/Streamly/Test/Prelude/WAsync.hs+5
@@ -47,6 +47,11 @@ main = hspec
47 wAsyncOps $ prop "wAsyncly consM" . constructWithConsM S.consM sort
47 wAsyncOps $ prop "wAsyncly consM" . constructWithConsM S.consM sort
48 wAsyncOps $ prop "wAsyncly (.:)" . constructWithCons (S..:)
48 wAsyncOps $ prop "wAsyncly (.:)" . constructWithCons (S..:)
49 wAsyncOps $ prop "wAsyncly (|:)" . constructWithConsM (S.|:) sort
49 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]
50
55
51 describe "Functor operations" $ do
56 describe "Functor operations" $ do
52 wAsyncOps $ functorOps S.fromFoldable "wAsyncly" sortEq
57 wAsyncOps $ functorOps S.fromFoldable "wAsyncly" sortEq
test/lib/Streamly/Test/Prelude/Common.hs+13
@@ -31,6 +31,7 @@ module Streamly.Test.Prelude.Common
31 , constructWithConsM
31 , constructWithConsM
32 , constructWithFromPure
32 , constructWithFromPure
33 , constructWithFromEffect
33 , constructWithFromEffect
34+ , constructfromWAsync
34 , simpleOps
35 , simpleOps
35 -- * Applicative operations
36 -- * Applicative operations
36 , applicativeOps
37 , applicativeOps
@@ -290,6 +291,18 @@ constructWithFromIndicesM op len =
290 streamEffect <- run $ readIORef mvl
291 streamEffect <- run $ readIORef mvl
291 listEquals (==) streamEffect list
292 listEquals (==) streamEffect list
292
293
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+
293constructWithCons ::
306constructWithCons ::
294 IsStream t
307 IsStream t
295 => (Int -> t IO Int -> t IO Int)
308 => (Int -> t IO Int -> t IO Int)