@@ -20,11 +20,22 @@ import Test.QuickCheck.Monadic (monadicIO, assert, run)
20import Test.Hspec as H
20import Test.Hspec as H
22import Streamly (SerialT)
22import Streamly (SerialT)
23−import Streamly.Data.Array (Array)
25−import qualified Streamly.Data.Array as A
26import qualified Streamly.Prelude as S
24import qualified Streamly.Prelude as S
26+#ifdef TEST_SMALL_ARRAY
27+import qualified Streamly.Data.SmallArray as A
28+type Array = A.SmallArray
29+#elif defined(TEST_ARRAY)
30+import qualified Streamly.Memory.Array as A
31+import qualified Streamly.Internal.Memory.Array as A
32+import qualified Streamly.Internal.Prelude as IP
35+import qualified Streamly.Data.Array as A
28-- Coverage build takes too long with default number of tests
39-- Coverage build takes too long with default number of tests
29maxTestCount :: Int
40maxTestCount :: Int
30#ifdef DEVBUILD
41#ifdef DEVBUILD
@@ -63,8 +74,10 @@ testLength = genericTestFrom (\n -> S.fold (A.writeN n))
63testLengthFromStreamN :: Property
74testLengthFromStreamN :: Property
64testLengthFromStreamN = genericTestFrom A.fromStreamN
75testLengthFromStreamN = genericTestFrom A.fromStreamN
77+#ifndef TEST_SMALL_ARRAY
66testLengthFromStream :: Property
78testLengthFromStream :: Property
67testLengthFromStream = genericTestFrom (const A.fromStream)
79testLengthFromStream = genericTestFrom (const A.fromStream)
69genericTestFromTo ::
82genericTestFromTo ::
70 (Int -> SerialT IO Int -> IO (Array Int))
83 (Int -> SerialT IO Int -> IO (Array Int))
@@ -100,11 +113,26 @@ testFromStreamNUnfold = genericTestFromTo A.fromStreamN (S.unfold A.read) (==)
100testFromStreamNToStream :: Property
113testFromStreamNToStream :: Property
101testFromStreamNToStream = genericTestFromTo A.fromStreamN A.toStream (==)
114testFromStreamNToStream = genericTestFromTo A.fromStreamN A.toStream (==)
116+#ifndef TEST_SMALL_ARRAY
103testFromStreamToStream :: Property
117testFromStreamToStream :: Property
104testFromStreamToStream = genericTestFromTo (const A.fromStream) A.toStream (==)
118testFromStreamToStream = genericTestFromTo (const A.fromStream) A.toStream (==)
106testFoldUnfold :: Property
120testFoldUnfold :: Property
107testFoldUnfold = genericTestFromTo (const (S.fold A.write)) (S.unfold A.read) (==)
121testFoldUnfold = genericTestFromTo (const (S.fold A.write)) (S.unfold A.read) (==)
125+testArraysOf :: Property
127+ forAll (choose (0, maxArrLen)) $ \len ->
128+ forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
131+ $ S.concatUnfold A.read
109main :: IO ()
137main :: IO ()
@@ -114,11 +142,16 @@ main =
114 describe "Construction" $ do
142 describe "Construction" $ do
115 prop "length . writeN n === n" testLength
143 prop "length . writeN n === n" testLength
116 prop "length . fromStreamN n === n" testLengthFromStreamN
144 prop "length . fromStreamN n === n" testLengthFromStreamN
117− prop "length . fromStream === n" testLengthFromStream
118 prop "read . writeN === id " testFoldNUnfold
145 prop "read . writeN === id " testFoldNUnfold
119 prop "toStream . writeN === id" testFoldNToStream
146 prop "toStream . writeN === id" testFoldNToStream
120 prop "toStreamRev . writeN === reverse" testFoldNToStreamRev
147 prop "toStreamRev . writeN === reverse" testFoldNToStreamRev
121 prop "read . fromStreamN === id" testFromStreamNUnfold
148 prop "read . fromStreamN === id" testFromStreamNUnfold
122 prop "toStream . fromStreamN === id" testFromStreamNToStream
149 prop "toStream . fromStreamN === id" testFromStreamNToStream
150+#ifndef TEST_SMALL_ARRAY
151+ prop "length . fromStream === n" testLengthFromStream
123 prop "toStream . fromStream === id" testFromStreamToStream
152 prop "toStream . fromStream === id" testFromStreamToStream
124 prop "read . write === id" testFoldUnfold
153 prop "read . write === id" testFoldUnfold
156+ prop "arraysOf concats to original" testArraysOf