@@ -31,8 +31,7 @@ import Streamly.Test.Common (listEquals)
3131
3232import qualified Streamly.Prelude as S
3333
34−#if defined(TEST_ARRAY) ||\
35− defined(DATA_ARRAY_PRIM) ||\
34+#if defined(DATA_ARRAY_PRIM) ||\
3635 defined(DATA_ARRAY_PRIM_PINNED)
3736import qualified Streamly.Internal.Data.Fold as Fold
3837#endif
@@ -40,14 +39,6 @@ import qualified Streamly.Internal.Data.Fold as Fold
4039#ifdef TEST_SMALL_ARRAY
4140import qualified Streamly.Internal.Data.SmallArray as A
4241type Array = A.SmallArray
43−#elif defined(TEST_ARRAY)
44−import Data.Word(Word8)
45−
46−import qualified Streamly.Internal.Data.Array.Foreign as A
47−import qualified Streamly.Internal.Data.Array.Foreign.Type as A
48−import qualified Streamly.Internal.Data.Array.Foreign.Mut.Type as MA
49−import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
50−type Array = A.Array
5142#elif defined(DATA_ARRAY_PRIM_PINNED)
5243import qualified Streamly.Internal.Data.Array.Prim.Pinned as A
5344import qualified Streamly.Internal.Data.Array.Prim.Pinned.Type as A
@@ -61,8 +52,6 @@ type Array = A.Array
6152moduleName :: String
6253#ifdef TEST_SMALL_ARRAY
6354moduleName = "Data.SmallArray"
64−#elif defined(TEST_ARRAY)
65−moduleName = "Data.Array.Foreign"
6655#elif defined(DATA_ARRAY_PRIM_PINNED)
6756moduleName = "Data.Array.Prim.Pinned"
6857#elif defined(DATA_ARRAY_PRIM)
@@ -185,55 +174,6 @@ foldManyWith f =
185174 $ S.fromList list
186175 assert (xs == list)
187176
188−#ifdef TEST_ARRAY
189−
190−unsafeWriteIndex :: [Int] -> Int -> Int -> IO Bool
191−unsafeWriteIndex xs i x = do
192− arr <- MA.fromList xs
193− MA.putIndexUnsafe arr i x
194− x1 <- MA.getIndexUnsafe arr i
195− return $ x1 == x
196−
197−lastN :: Int -> [a] -> [a]
198−lastN n l = drop (length l - n) l
199−
200−testLastN :: Property
201−testLastN =
202− forAll (choose (0, maxArrLen)) $ \len ->
203− forAll (choose (0, len)) $ \n ->
204− forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
205− monadicIO $ do
206− xs <- run
207− $ fmap A.toList
208− $ S.fold (A.writeLastN n)
209− $ S.fromList list
210− assert (xs == lastN n list)
211−
212−testLastN_LN :: Int -> Int -> IO Bool
213−testLastN_LN len n = do
214− let list = [1..len]
215− l1 <- fmap A.toList $ S.fold (A.writeLastN n) $ S.fromList list
216− let l2 = lastN n list
217− return $ l1 == l2
218−
219−-- Instead of hard coding 10000 here we can have maxStreamLength for operations
220−-- that use stream of arrays.
221−concatArrayW8 :: Property
222−concatArrayW8 =
223− forAll (vectorOf 10000 (arbitrary :: Gen Word8))
224− $ \w8List -> do
225− let w8ArrList = A.fromList . (: []) <$> w8List
226− f2 <- S.toList $ AS.concat $ S.fromList w8ArrList
227− w8List `shouldBe` f2
228−
229−unsafeSlice :: Int -> Int -> [Int] -> Bool
230−unsafeSlice i n list =
231− let lst = take n $ drop i $ list
232− arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
233− in arr == lst
234−
235−#endif
236−
237177main :: IO ()
238178main =
239179 hspec $
@@ -257,30 +197,10 @@ main =
257197 prop "fromList" testFromList
258198#endif
259199
260−#if defined(TEST_ARRAY) ||\
261− defined(DATA_ARRAY_PRIM) ||\
200+#if defined(DATA_ARRAY_PRIM) ||\
262201 defined(DATA_ARRAY_PRIM_PINNED)
263202 prop "foldMany with writeNUnsafe concats to original"
264203 (foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
265204#endif
266205 prop "foldMany with writeN concats to original"
267206 (foldManyWith A.writeN)
268−
269−#ifdef TEST_ARRAY
270− prop "AS.concat . (A.fromList . (:[]) <$>) === id" $ concatArrayW8
271− describe "unsafeSlice" $ do
272− it "partial" $ unsafeSlice 2 4 [1..10]
273− it "none" $ unsafeSlice 10 0 [1..10]
274− it "full" $ unsafeSlice 0 10 [1..10]
275− describe "Mut.unsafeWriteIndex" $ do
276− it "first" (unsafeWriteIndex [1..10] 0 0 `shouldReturn` True)
277− it "middle" (unsafeWriteIndex [1..10] 5 0 `shouldReturn` True)
278− it "last" (unsafeWriteIndex [1..10] 9 0 `shouldReturn` True)
279− describe "Fold" $ do
280− prop "writeLastN : 0 <= n <= len" $ testLastN
281− describe "writeLastN boundary conditions" $ do
282− it "writeLastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
283− it "writeLastN 0" (testLastN_LN 10 0 `shouldReturn` True)
284− it "writeLastN length" (testLastN_LN 10 10 `shouldReturn` True)
285− it "writeLastN (length + 1)" (testLastN_LN 10 11 `shouldReturn` True)
286−#endif