mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Add tests for cons, consM, .:, |:.
This commit is contained in:
parent
287e9edbf8
commit
57f43838a5
@ -55,6 +55,10 @@ main = hspec
|
||||
|
||||
describe "Construction" $ do
|
||||
aheadOps $ prop "aheadly replicateM" . constructWithReplicateM
|
||||
aheadOps $ prop "aheadly cons" . constructWithCons S.cons
|
||||
aheadOps $ prop "aheadly consM" . constructWithConsM S.consM id
|
||||
aheadOps $ prop "aheadly (.:)" . constructWithCons (S..:)
|
||||
aheadOps $ prop "aheadly (|:)" . constructWithConsM (S.|:) id
|
||||
|
||||
describe "Functor operations" $ do
|
||||
aheadOps $ functorOps S.fromFoldable "aheadly" (==)
|
||||
@ -121,7 +125,7 @@ main = hspec
|
||||
describe "Stream serial elimination operations" $ do
|
||||
aheadOps $ eliminationOpsOrdered S.fromFoldable "aheadly"
|
||||
aheadOps $ eliminationOpsOrdered folded "aheadly folded"
|
||||
|
||||
|
||||
describe "Composed MonadThrow aheadly" $ composeWithMonadThrow S.aheadly
|
||||
|
||||
-- Ad-hoc tests
|
||||
|
@ -36,6 +36,10 @@ main = hspec
|
||||
|
||||
describe "Construction" $ do
|
||||
asyncOps $ prop "asyncly replicateM" . constructWithReplicateM
|
||||
asyncOps $ prop "asyncly cons" . constructWithCons S.cons
|
||||
asyncOps $ prop "asyncly consM" . constructWithConsM S.consM sort
|
||||
asyncOps $ prop "asyncly (.:)" . constructWithCons (S..:)
|
||||
asyncOps $ prop "asyncly (|:)" . constructWithConsM (S.|:) sort
|
||||
|
||||
describe "Functor operations" $ do
|
||||
asyncOps $ functorOps S.fromFoldable "asyncly" sortEq
|
||||
|
@ -20,6 +20,8 @@ module Streamly.Test.Prelude.Common
|
||||
, constructWithIterateM
|
||||
, constructWithFromIndices
|
||||
, constructWithFromIndicesM
|
||||
, constructWithCons
|
||||
, constructWithConsM
|
||||
-- * Applicative operations
|
||||
, applicativeOps
|
||||
, applicativeOps1
|
||||
@ -251,6 +253,39 @@ constructWithFromIndicesM op len =
|
||||
streamEffect <- run $ readIORef mvl
|
||||
listEquals (==) streamEffect list
|
||||
|
||||
constructWithCons ::
|
||||
IsStream t
|
||||
=> (Int -> t IO Int -> t IO Int)
|
||||
-> (t IO Int -> SerialT IO Int)
|
||||
-> Word8
|
||||
-> Property
|
||||
constructWithCons cons op len =
|
||||
withMaxSuccess maxTestCount $
|
||||
monadicIO $ do
|
||||
strm <-
|
||||
run $
|
||||
S.toList . op . S.take (fromIntegral len) $
|
||||
foldr cons S.nil (repeat 0)
|
||||
let list = replicate (fromIntegral len) 0
|
||||
listEquals (==) strm list
|
||||
|
||||
constructWithConsM ::
|
||||
IsStream t
|
||||
=> (IO Int -> t IO Int -> t IO Int)
|
||||
-> ([Int] -> [Int])
|
||||
-> (t IO Int -> SerialT IO Int)
|
||||
-> Word8
|
||||
-> Property
|
||||
constructWithConsM consM listT op len =
|
||||
withMaxSuccess maxTestCount $
|
||||
monadicIO $ do
|
||||
strm <-
|
||||
run $
|
||||
S.toList . op . S.take (fromIntegral len) $
|
||||
foldr consM S.nil (repeat (return 0))
|
||||
let list = replicate (fromIntegral len) 0
|
||||
listEquals (==) (listT strm) list
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Applicative operations
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -40,6 +40,10 @@ main = hspec
|
||||
|
||||
describe "Construction" $ do
|
||||
parallelOps $ prop "parallely replicateM" . constructWithReplicateM
|
||||
parallelOps $ prop "parallely cons" . constructWithCons S.cons
|
||||
-- parallelOps $ prop "parallely consM" . constructWithConsM S.consM sort
|
||||
parallelOps $ prop "parallely (.:)" . constructWithCons (S..:)
|
||||
-- parallelOps $ prop "parallely (|:)" . constructWithConsM (S.|:) sort
|
||||
|
||||
describe "Functor operations" $ do
|
||||
parallelOps $ functorOps S.fromFoldable "parallely" sortEq
|
||||
|
@ -470,6 +470,10 @@ main = hspec
|
||||
serialOps $ prop "serially iterateM" . constructWithIterateM
|
||||
serialOps $ prop "serially fromIndices" . constructWithFromIndices
|
||||
serialOps $ prop "serially fromIndicesM" . constructWithFromIndicesM
|
||||
serialOps $ prop "serially cons" . constructWithCons S.cons
|
||||
serialOps $ prop "serially consM" . constructWithConsM S.consM id
|
||||
serialOps $ prop "serially (.:)" . constructWithCons (S..:)
|
||||
serialOps $ prop "serially (|:)" . constructWithConsM (S.|:) id
|
||||
|
||||
describe "From Generators" $ do
|
||||
prop "unfold" unfold
|
||||
|
@ -40,6 +40,10 @@ main = hspec
|
||||
describe "Construction" $ do
|
||||
wAsyncOps $ prop "wAsyncly replicateM" . constructWithReplicateM
|
||||
-- XXX add tests for fromIndices
|
||||
wAsyncOps $ prop "wAsyncly cons" . constructWithCons S.cons
|
||||
wAsyncOps $ prop "wAsyncly consM" . constructWithConsM S.consM sort
|
||||
wAsyncOps $ prop "wAsyncly (.:)" . constructWithCons (S..:)
|
||||
wAsyncOps $ prop "wAsyncly (|:)" . constructWithConsM (S.|:) sort
|
||||
|
||||
describe "Functor operations" $ do
|
||||
wAsyncOps $ functorOps S.fromFoldable "wAsyncly" sortEq
|
||||
@ -93,7 +97,7 @@ main = hspec
|
||||
wAsyncOps $ eliminationOps folded "wAsyncly folded"
|
||||
wAsyncOps $ eliminationOpsWord8 S.fromFoldable "wAsyncly"
|
||||
wAsyncOps $ eliminationOpsWord8 folded "wAsyncly folded"
|
||||
|
||||
|
||||
-- describe "WAsync interleaved (<>) ordering check" $
|
||||
-- interleaveCheck wAsyncly (<>)
|
||||
-- describe "WAsync interleaved mappend ordering check" $
|
||||
|
@ -71,6 +71,10 @@ main = hspec
|
||||
|
||||
describe "Construction" $ do
|
||||
wSerialOps $ prop "wSerially replicateM" . constructWithReplicateM
|
||||
wSerialOps $ prop "wSerially cons" . constructWithCons S.cons
|
||||
wSerialOps $ prop "wSerially consM" . constructWithConsM S.consM id
|
||||
wSerialOps $ prop "wSerially (.:)" . constructWithCons (S..:)
|
||||
wSerialOps $ prop "wSerially (|:)" . constructWithConsM (S.|:) id
|
||||
|
||||
describe "Functor operations" $ do
|
||||
wSerialOps $ functorOps S.fromFoldable "wSerially" (==)
|
||||
|
Loading…
Reference in New Issue
Block a user