on ea224a4 help sign in
52 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
14import qualified Streamly.Internal.Data.Fold as Fold
16type Array = A.Array
18moduleName :: String
19moduleName = "Data.Array"
21#include "Streamly/Test/Data/Array/Common.hs"
23testFromStreamToStream :: Property
24testFromStreamToStream = genericTestFromTo (const A.fromStream) A.toStream (==)
26testFoldUnfold :: Property
27testFoldUnfold = genericTestFromTo (const (S.fold A.write)) (S.unfold A.read) (==)
29testFromList :: Property
30testFromList =
31 forAll (choose (0, maxArrLen)) $ \len ->
32 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
33 monadicIO $ do
34 let arr = A.fromList list
35 xs <- run $ S.fold Fold.toList $ S.unfold A.read arr
36 assert (xs == list)
38testLengthFromStream :: Property
39testLengthFromStream = genericTestFrom (const A.fromStream)
41main :: IO ()
42main =
43 hspec $
44 H.parallel $
45 modifyMaxSuccess (const maxTestCount) $ do
46 describe moduleName $ do
47 commonMain
48 describe "Construction" $ do
49 prop "length . fromStream === n" testLengthFromStream
50 prop "toStream . fromStream === id" testFromStreamToStream
51 prop "read . write === id" testFoldUnfold
52 prop "fromList" testFromList