on 30c98dc help sign in
51 lines 1.6 kB history raw
1-- |
2-- Module : Streamly.Test.Data.Array
3-- Copyright : (c) 2019 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
7-- Portability : GHC
9module Streamly.Test.Data.Array (main) where
11#include "Streamly/Test/Data/Array/CommonImports.hs"
13import qualified Streamly.Internal.Data.Array as A
15type Array = A.Array
17moduleName :: String
18moduleName = "Data.Array"
20#include "Streamly/Test/Data/Array/Common.hs"
22testFromStreamToStream :: Property
23testFromStreamToStream = genericTestFromTo (const A.fromStream) A.toStream (==)
25testFoldUnfold :: Property
26testFoldUnfold = genericTestFromTo (const (S.fold A.write)) (S.unfold A.read) (==)
28testFromList :: Property
29testFromList =
30 forAll (choose (0, maxArrLen)) $ \len ->
31 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
32 monadicIO $ do
33 let arr = A.fromList list
34 xs <- run $ S.fold Fold.toList $ S.unfold A.read arr
35 assert (xs == list)
37testLengthFromStream :: Property
38testLengthFromStream = genericTestFrom (const A.fromStream)
40main :: IO ()
41main =
42 hspec $
43 H.parallel $
44 modifyMaxSuccess (const maxTestCount) $ do
45 describe moduleName $ do
46 commonMain
47 describe "Construction" $ do
48 prop "length . fromStream === n" testLengthFromStream
49 prop "toStream . fromStream === id" testFromStreamToStream
50 prop "read . write === id" testFoldUnfold
51 prop "fromList" testFromList