2{-# LANGUAGE FlexibleContexts #-}
4module Main (main) where
6import Foreign.Storable (Storable(..))
8import Test.Hspec.QuickCheck
9import Test.QuickCheck (Property, forAll, Gen, vectorOf, arbitrary, choose)
10import Test.QuickCheck.Monadic (monadicIO, assert)
14import qualified Streamly.Mem.Array as A
15import qualified Streamly.Mem.Array.Stream as AS
16import qualified Streamly.Prelude as S
18-- Coverage build takes too long with default number of tests
27allocOverhead = 2 * sizeOf (undefined :: Int)
29-- XXX this should be in sync with the defaultChunkSize in Array code, or we
30-- should expose that and use that. For fast testing we could reduce the
31-- defaultChunkSize under CPP conditionals.
33defaultChunkSize :: Int
34defaultChunkSize = 32 * k - allocOverhead
38maxArrLen = defaultChunkSize * 8
42 forAll (choose (0, maxArrLen)) $ \len ->
43 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
47 assert (A.length arr == len)
49testFromToStreamN :: Property
51 forAll (choose (0, maxArrLen)) $ \len ->
52 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
60testToStreamRev :: Property
62 forAll (choose (0, maxArrLen)) $ \len ->
63 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
69 assert (xs == reverse list)
71testArraysOf :: Property
73 forAll (choose (0, maxArrLen)) $ \len ->
74 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
82testFlattenArrays :: Property
84 forAll (choose (0, maxArrLen)) $ \len ->
85 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
93testFromToStream :: Property
95 forAll (choose (0, maxArrLen)) $ \len ->
96 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
98 arr <- A.write $ S.fromList list
106 $ modifyMaxSuccess (const maxTestCount)
108 describe "Construction" $ do
109 prop "length . writeN n === n" $ testLength
110 prop "read . writeN n === id" $ testFromToStreamN
111 prop "readRev . write === reverse" $ testToStreamRev
112 prop "arraysOf concats to original" $ testArraysOf
113 prop "flattenArrays concats to original" $ testFlattenArrays
114 prop "read . write === id" $ testFromToStream
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