@@ -11,13 +11,16 @@ module Streamly.Test.Data.Array.Foreign (main) where
11#include "Streamly/Test/Data/Array/CommonImports.hs"
11#include "Streamly/Test/Data/Array/CommonImports.hs"
13import Data.Char (isLower)
13import Data.Char (isLower)
14+import Data.List (sort)
14import Data.Word(Word8)
15import Data.Word(Word8)
16+import Test.QuickCheck (chooseInt, listOf)
16import qualified Streamly.Internal.Data.Fold as Fold
18import qualified Streamly.Internal.Data.Fold as Fold
17import qualified Streamly.Internal.Data.Array.Foreign as A
19import qualified Streamly.Internal.Data.Array.Foreign as A
18import qualified Streamly.Internal.Data.Array.Foreign.Type as A
20import qualified Streamly.Internal.Data.Array.Foreign.Type as A
19import qualified Streamly.Internal.Data.Array.Foreign.Mut.Type as MA
21import qualified Streamly.Internal.Data.Array.Foreign.Mut.Type as MA
20import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
22import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
21type Array = A.Array
24type Array = A.Array
23moduleName :: String
26moduleName :: String
@@ -131,6 +134,43 @@ unsafeSlice i n list =
131 arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
134 arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
132 in arr == lst
135 in arr == lst
138+testAppend :: Property
140+ forAll (listOf (chooseInt (-50, 100))) $ \ls0 ->
141+ monadicIO $ action ls0
147+ (MA.append (MA.newArray 0))
148+ (S.fromList (ls::[Int]))
153+testBubbleAsc :: Property
155+ forAll (listOf (chooseInt (-50, 100))) $ \ls0 ->
156+ monadicIO $ action ls0
161+ x <- S.fold (fldm ls) $ S.fromList ls
163+ assert (sort ls == lst)
169+ MA.bubbleAsc compare arr
172+ (MA.newArray $ length ls)
134main :: IO ()
174main :: IO ()
@@ -139,6 +179,9 @@ main =
139 describe moduleName $ do
179 describe moduleName $ do
140 commonMain
180 commonMain
141 describe "Construction" $ do
181 describe "Construction" $ do
182+ -- XXX There is an issue https://github.com/composewell/streamly/issues/1577
183+ --prop "testAppend" testAppend
184+ prop "testBubbleAsc" testBubbleAsc
142 prop "length . fromStream === n" testLengthFromStream
185 prop "length . fromStream === n" testLengthFromStream
143 prop "toStream . fromStream === id" testFromStreamToStream
186 prop "toStream . fromStream === id" testFromStreamToStream
144 prop "read . write === id" testFoldUnfold
187 prop "read . write === id" testFoldUnfold