on 326b055 help sign in
63 lines 2.0 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 =
24 genericTestFromTo (const A.fromStream) A.read (==)
26testFoldUnfold :: Property
27testFoldUnfold =
28 genericTestFromTo (const (S.fold A.write)) (S.unfold A.reader) (==)
30testFromList :: Property
31testFromList =
32 forAll (choose (0, maxArrLen)) $ \len ->
33 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
34 monadicIO $ do
35 let arr = A.fromList list
36 xs <- run $ S.fold Fold.toList $ S.unfold A.reader arr
37 assert (xs == list)
39testLengthFromStream :: Property
40testLengthFromStream = genericTestFrom (const A.fromStream)
42testReadShowInstance :: Property
43testReadShowInstance =
44 forAll (choose (0, maxArrLen)) $ \len ->
45 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
46 monadicIO $ do
47 let arr = A.fromList list
48 assert (A.toList (read (show arr)) == list)
51main :: IO ()
52main =
53 hspec $
54 H.parallel $
55 modifyMaxSuccess (const maxTestCount) $ do
56 describe moduleName $ do
57 commonMain
58 describe "Construction" $ do
59 prop "length . fromStream === n" testLengthFromStream
60 prop "toStream . fromStream === id" testFromStreamToStream
61 prop "read . write === id" testFoldUnfold
62 prop "fromList" testFromList
63 prop "testReadShowInstance" testReadShowInstance