@@ -4,8 +4,6 @@ import qualified Streamly.Internal.Data.Parser.ParserD as D
4import qualified Streamly.Internal.Prelude as S
4import qualified Streamly.Internal.Prelude as S
5import qualified Streamly.Internal.Data.Fold as FL
5import qualified Streamly.Internal.Data.Fold as FL
7−import Data.List (partition)
9import Test.Hspec(hspec, describe)
7import Test.Hspec(hspec, describe)
10import Test.Hspec.QuickCheck
8import Test.Hspec.QuickCheck
11import Test.QuickCheck (forAll, chooseInt, Property, property, listOf, vectorOf, (.&&.))
9import Test.QuickCheck (forAll, chooseInt, Property, property, listOf, vectorOf, (.&&.))
@@ -238,17 +236,53 @@ teeWith =
238 Right _ -> False
236 Right _ -> False
239 Left _ -> True)
237 Left _ -> True)
241−-- deintercalate :: Property
239+shortest :: Property
242−-- deintercalate =
240+shortest =
243−-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
241+ forAll (listOf (chooseInt(0, 10000))) $ \ls ->
244−-- case S.parseD (D.deintercalate concatFold prsr_1 concatFold prsr_2) (S.fromList ls) of
242+ let
245−-- Right parsed_list_tuple -> parsed_list_tuple == partition (== 0) ls
243+ prsr_1 = D.takeWhile (<= 2500) FL.toList
244+ prsr_2 = D.takeWhile (<= 5000) FL.toList
245+ prsr_shortest = D.shortest prsr_1 prsr_2
247+ case S.parseD prsr_shortest (S.fromList ls) of
248+ Right short_list -> short_list == Prelude.takeWhile (<= 2500) ls
251+ property (case S.parseD (D.shortest (D.die "die") (D.yield (1 :: Int))) (S.fromList [1 :: Int]) of
255+ property (case S.parseD (D.shortest (D.yield (1 :: Int)) (D.die "die")) (S.fromList [1 :: Int]) of
259+ property (case S.parseD (D.shortest (D.die "die") (D.die "die")) (S.fromList [1 :: Int]) of
246−-- Left _ -> False
261+ Left _ -> True)
248−-- where
263+longest :: Property
249−-- prsr_1 = (D.takeWhile (== 0) FL.toList)
264+longest =
250−-- prsr_2 = (D.takeWhile (== 1) FL.toList)
265+ forAll (listOf (chooseInt(0, 10000))) $ \ls ->
251−-- concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
266+ let
267+ prsr_1 = D.takeWhile (<= 2500) FL.toList
268+ prsr_2 = D.takeWhile (<= 5000) FL.toList
269+ prsr_longest = D.longest prsr_1 prsr_2
271+ case S.parseD prsr_longest (S.fromList ls) of
272+ Right long_list -> long_list == Prelude.takeWhile (<= 5000) ls
275+ property (case S.parseD (D.shortest (D.die "die") (D.yield (1 :: Int))) (S.fromList [1 :: Int]) of
279+ property (case S.parseD (D.shortest (D.yield (1 :: Int)) (D.die "die")) (S.fromList [1 :: Int]) of
283+ property (case S.parseD (D.shortest (D.die "die") (D.die "die")) (S.fromList [1 :: Int]) of
253main :: IO ()
287main :: IO ()
254main = hspec $ do
288main = hspec $ do
@@ -277,4 +311,5 @@ main = hspec $ do
277 -- prop "test for sliceSepByMax function" sliceSepByMax
311 -- prop "test for sliceSepByMax function" sliceSepByMax
278 prop "test for splitWith function" splitWith
312 prop "test for splitWith function" splitWith
279 prop "test for teeWith function" teeWith
313 prop "test for teeWith function" teeWith
314+ prop "test for shortest function" shortest
280− -- prop "test for deintercalate function" deintercalate
315+ prop "test for longest function" longest