Add a simple test for ArrayStream.concat

This commit is contained in:
Adithya Kumar 2020-12-28 22:36:25 +05:30 committed by Adithya Kumar
parent d2f70e40cf
commit 6bc64a47ba

View File

@ -26,9 +26,12 @@ import qualified Streamly.Prelude as S
import qualified Streamly.Internal.Data.SmallArray as A
type Array = A.SmallArray
#elif defined(TEST_ARRAY)
import Data.Word(Word8)
import qualified Streamly.Internal.Data.Array.Storable.Foreign as A
import qualified Streamly.Internal.Data.Array.Storable.Foreign.Types as A
import qualified Streamly.Internal.Data.Stream.IsStream as IP
import qualified Streamly.Internal.Memory.ArrayStream as AS
type Array = A.Array
#elif defined(DATA_ARRAY_PRIM_PINNED)
import qualified Streamly.Internal.Data.Array.Prim.Pinned as A
@ -173,6 +176,17 @@ testLastN_LN len n = do
l1 <- fmap A.toList $ S.fold (A.lastN n) $ S.fromList list
let l2 = lastN n list
return $ l1 == l2
-- Instead of hard coding 10000 here we can have maxStreamLength for operations
-- that use stream of arrays.
concatArrayW8 :: Property
concatArrayW8 =
forAll (vectorOf 10000 (arbitrary :: Gen Word8))
$ \w8List -> do
let w8ArrList = A.fromList . (: []) <$> w8List
f2 <- S.toList $ AS.concat $ S.fromList w8ArrList
w8List `shouldBe` f2
#endif
main :: IO ()
@ -201,6 +215,7 @@ main =
#endif
#ifdef TEST_ARRAY
prop "AS.concat . (A.fromList . (:[]) <$>) === id" $ concatArrayW8
describe "Fold" $ do
prop "lastN : 0 <= n <= len" $ testLastN
describe "lastN boundary conditions" $ do