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