@@ -1,12 +1,12 @@
2−-- Module : Streamly.Test.Data.Array.Foreign
2+-- Module : Streamly.Test.Data.Array.Unboxed
3-- Copyright : (c) 2019 Composewell technologies
3-- Copyright : (c) 2019 Composewell technologies
4-- License : BSD-3-Clause
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
6-- Stability : experimental
7-- Portability : GHC
7-- Portability : GHC
9−module Streamly.Test.Data.Array.Foreign (main) where
9+module Streamly.Test.Data.Array.Unboxed (main) where
11#include "Streamly/Test/Data/Array/CommonImports.hs"
11#include "Streamly/Test/Data/Array/CommonImports.hs"
@@ -27,7 +27,7 @@ import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
27type Array = A.Array
27type Array = A.Array
29moduleName :: String
29moduleName :: String
30−moduleName = "Data.Array.Foreign"
30+moduleName = "Data.Array.Unboxed"
32#include "Streamly/Test/Data/Array/Common.hs"
32#include "Streamly/Test/Data/Array/Common.hs"
@@ -43,7 +43,7 @@ testFromList =
43 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
43 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
44 monadicIO $ do
44 monadicIO $ do
45 let arr = A.fromList list
45 let arr = A.fromList list
46− xs <- run $ S.toList $ (S.unfold A.read) arr
46+ xs <- run $ S.toList $ S.unfold A.read arr
47 assert (xs == list)
47 assert (xs == list)
49testLengthFromStream :: Property
49testLengthFromStream :: Property
@@ -133,7 +133,7 @@ concatArrayW8 =
134unsafeSlice :: Int -> Int -> [Int] -> Bool
134unsafeSlice :: Int -> Int -> [Int] -> Bool
135unsafeSlice i n list =
135unsafeSlice i n list =
136− let lst = take n $ drop i $ list
136+ let lst = take n $ drop i list
137 arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
137 arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
138 in arr == lst
138 in arr == lst
@@ -190,7 +190,7 @@ testByteLengthWithMA _ = do
190 let arrW8 = MA.castUnsafe arrA :: MA.Array Word8
190 let arrW8 = MA.castUnsafe arrA :: MA.Array Word8
191 MA.byteLength arrA `shouldBe` MA.length arrW8
191 MA.byteLength arrA `shouldBe` MA.length arrW8
193−testBreakOn :: [Word8] -> Word8 -> [Word8] -> (Maybe [Word8]) -> IO ()
193+testBreakOn :: [Word8] -> Word8 -> [Word8] -> Maybe [Word8] -> IO ()
194testBreakOn inp sep bef aft = do
194testBreakOn inp sep bef aft = do
195 (bef_, aft_) <- A.breakOn sep (A.fromList inp)
195 (bef_, aft_) <- A.breakOn sep (A.fromList inp)
196 bef_ `shouldBe` A.fromList bef
196 bef_ `shouldBe` A.fromList bef
@@ -207,7 +207,7 @@ testFromToList inp = A.toList (A.fromList inp) `shouldBe` inp
207testUnsafeIndxedFromList :: [Char] -> IO ()
207testUnsafeIndxedFromList :: [Char] -> IO ()
208testUnsafeIndxedFromList inp =
208testUnsafeIndxedFromList inp =
209 let arr = A.fromList inp
209 let arr = A.fromList inp
210− in fmap (flip A.unsafeIndex arr) [0 .. (length inp - 1)] `shouldBe` inp
210+ in fmap (`A.unsafeIndex` arr) [0 .. (length inp - 1)] `shouldBe` inp
212testAsPtrUnsafeMA :: IO ()
212testAsPtrUnsafeMA :: IO ()
213testAsPtrUnsafeMA = do
213testAsPtrUnsafeMA = do
@@ -257,7 +257,7 @@ main =
257 prop "fromList" testFromList
257 prop "fromList" testFromList
258 prop "foldMany with writeNUnsafe concats to original"
258 prop "foldMany with writeNUnsafe concats to original"
259 (foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
259 (foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
260− prop "AS.concat . (A.fromList . (:[]) <$>) === id" $ concatArrayW8
260+ prop "AS.concat . (A.fromList . (:[]) <$>) === id" concatArrayW8
261 describe "unsafeSlice" $ do
261 describe "unsafeSlice" $ do
262 it "partial" $ unsafeSlice 2 4 [1..10]
262 it "partial" $ unsafeSlice 2 4 [1..10]
263 it "none" $ unsafeSlice 10 0 [1..10]
263 it "none" $ unsafeSlice 10 0 [1..10]
@@ -267,7 +267,7 @@ main =
267 it "middle" (unsafeWriteIndex [1..10] 5 0 `shouldReturn` True)
267 it "middle" (unsafeWriteIndex [1..10] 5 0 `shouldReturn` True)
268 it "last" (unsafeWriteIndex [1..10] 9 0 `shouldReturn` True)
268 it "last" (unsafeWriteIndex [1..10] 9 0 `shouldReturn` True)
269 describe "Fold" $ do
269 describe "Fold" $ do
270− prop "writeLastN : 0 <= n <= len" $ testLastN
270+ prop "writeLastN : 0 <= n <= len" testLastN
271 describe "writeLastN boundary conditions" $ do
271 describe "writeLastN boundary conditions" $ do
272 it "writeLastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
272 it "writeLastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
273 it "writeLastN 0" (testLastN_LN 10 0 `shouldReturn` True)
273 it "writeLastN 0" (testLastN_LN 10 0 `shouldReturn` True)