2-- Module : Streamly.Test.Data.Array.Prim
3-- Copyright : (c) 2020 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
9module Streamly.Test.Data.Array.Prim (main) where
11#include "Streamly/Test/Data/Array/CommonImports.hs"
13import qualified Streamly.Internal.Data.Fold as Fold
14import qualified Streamly.Internal.Data.Array.Prim as A
15import qualified Streamly.Internal.Data.Array.Prim.Type as A
19moduleName = "Data.Array.Prim"
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
31 forAll (choose (0, maxArrLen)) $ \len ->
32 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
34 let arr = A.fromList list
35 xs <- run $ S.toList $ (S.unfold A.read) arr
38testLengthFromStream :: Property
39testLengthFromStream = genericTestFrom (const A.fromStream)
46 modifyMaxSuccess (const maxTestCount) $ do
47 describe moduleName $ do
49 describe "Construction" $ do
50 prop "length . fromStream === n" testLengthFromStream
51 prop "toStream . fromStream === id" testFromStreamToStream
52 prop "read . write === id" testFoldUnfold
53 prop "fromList" testFromList
54 prop "foldMany with writeNUnsafe concats to original"
55 (foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list