on master help sign in
Fix test cases for StreamD/StreamK split up
8629a0eRanjeet Kumar Ranjan
.hlint.ignore+1
@@ -9,6 +9,7 @@ test/Streamly/Test/Data/SmallArray.hs
9test/Streamly/Test/Data/Unfold.hs
9test/Streamly/Test/Data/Unfold.hs
10test/Streamly/Test/FileSystem/Event.hs
10test/Streamly/Test/FileSystem/Event.hs
11test/Streamly/Test/Prelude/Concurrent.hs
11test/Streamly/Test/Prelude/Concurrent.hs
12+test/Streamly/Test/Data/Stream/Concurrent.hs
12test/Streamly/Test/Prelude/Fold.hs
13test/Streamly/Test/Prelude/Fold.hs
13test/Streamly/Test/Prelude/Rate.hs
14test/Streamly/Test/Prelude/Rate.hs
14test/Streamly/Test/Prelude/Serial.hs
15test/Streamly/Test/Prelude/Serial.hs
targets/Targets.hs+1−1
@@ -207,6 +207,6 @@ targets =
207 , ("Network.Inet.TCP", ["noBench"])
207 , ("Network.Inet.TCP", ["noBench"])
208 , ("version-bounds", ["noBench"])
208 , ("version-bounds", ["noBench"])
209
209
210− , ("Data.List", ["list_grp", "noBench"])
210+ , ("Data.List", ["list_grp", "noBench", "testDevOnly"])
211 , ("Data.List.Base", ["list_grp", "noBench"])
211 , ("Data.List.Base", ["list_grp", "noBench"])
212 ]
212 ]
test/Streamly/Test/Data/Array/Stream.hs+3−2
@@ -55,11 +55,12 @@ parseBreak = do
55 monadicIO $ do
55 monadicIO $ do
56 (ls1, str) <-
56 (ls1, str) <-
57 let input =
57 let input =
58+ Stream.toStreamK
58− chunksOf
59+ $ chunksOf
59 clen (Array.writeN clen) (Stream.fromList ls)
60 clen (Array.writeN clen) (Stream.fromList ls)
60 parser = Parser.fromFold (Fold.take tlen Fold.toList)
61 parser = Parser.fromFold (Fold.take tlen Fold.toList)
61 in run $ ArrayStream.parseBreak parser input
62 in run $ ArrayStream.parseBreak parser input
62− ls2 <- run $ Stream.fold Fold.toList (ArrayStream.concat str)
63+ ls2 <- run $ Stream.fold Fold.toList (ArrayStream.concat $ Stream.fromStreamK str)
63 case ls1 of
64 case ls1 of
64 Right x -> listEquals (==) (x ++ ls2) ls
65 Right x -> listEquals (==) (x ++ ls2) ls
65 Left _ -> assert False
66 Left _ -> assert False
test/Streamly/Test/Data/Parser/Chunked.hs+1−1
@@ -686,7 +686,7 @@ some =
686
686
687parse :: (Monad f, Unbox a) =>
687parse :: (Monad f, Unbox a) =>
688 P.ChunkParser a f b -> S.Stream f (A.Array a) -> f (Either ParseError b)
688 P.ChunkParser a f b -> S.Stream f (A.Array a) -> f (Either ParseError b)
689−parse parser stream = fmap fst (P.parseBreak parser stream)
689+parse parser stream = fmap fst (P.parseBreak parser $ S.toStreamK stream)
690
690
691applicative :: Property
691applicative :: Property
692applicative =
692applicative =
test/Streamly/Test/Data/Parser/ParserD.hs+1
@@ -13,6 +13,7 @@ import Test.QuickCheck.Monadic (monadicIO, assert, run)
13
13
14import qualified Data.List as List
14import qualified Data.List as List
15import qualified Prelude
15import qualified Prelude
16+import qualified Streamly.Data.Stream as S
16import qualified Streamly.Internal.Data.Array as A
17import qualified Streamly.Internal.Data.Array as A
17import qualified Streamly.Internal.Data.Fold as FL
18import qualified Streamly.Internal.Data.Fold as FL
18import qualified Streamly.Internal.Data.Parser.ParserD as P
19import qualified Streamly.Internal.Data.Parser.ParserD as P
test/Streamly/Test/Data/Stream/Concurrent.hs+4−4
@@ -131,10 +131,10 @@ exceptionPropagation f = do
131 (Left (ExampleException "E") :: Either ExampleException [Int])
131 (Left (ExampleException "E") :: Either ExampleException [Int])
132 it "append nested throwM" $ do
132 it "append nested throwM" $ do
133 let nested =
133 let nested =
134− Stream.fromFoldable [1..10]
134+ (Stream.fromList [1..10])
135 `f` Stream.fromEffect (throwM (ExampleException "E"))
135 `f` Stream.fromEffect (throwM (ExampleException "E"))
136− `f` Stream.fromFoldable [1..10]
136+ `f` (Stream.fromList [1..10])
137− try (tl (Stream.nil `f` nested `f` Stream.fromFoldable [1..10]))
137+ try (tl (Stream.nil `f` nested `f` (Stream.fromList [1..10])))
138 `shouldReturn`
138 `shouldReturn`
139 (Left (ExampleException "E")
139 (Left (ExampleException "E")
140 :: Either ExampleException [Int])
140 :: Either ExampleException [Int])
@@ -182,7 +182,7 @@ timeOrdering f = do
182
182
183takeCombined :: Int -> IO ()
183takeCombined :: Int -> IO ()
184takeCombined n = do
184takeCombined n = do
185− let constr = Stream.fromFoldable
185+ let constr = Stream.fromList
186 let s = Async.parList id [constr ([] :: [Int]), constr ([] :: [Int])]
186 let s = Async.parList id [constr ([] :: [Int]), constr ([] :: [Int])]
187 r <- Stream.fold Fold.toList $ Stream.take n s
187 r <- Stream.fold Fold.toList $ Stream.take n s
188 r `shouldBe` []
188 r `shouldBe` []
test/Streamly/Test/FileSystem/Event/Common.hs+5−3
@@ -66,7 +66,8 @@ import System.IO.Temp (withSystemTempDirectory)
66
66
67import qualified Data.List.NonEmpty as NonEmpty
67import qualified Data.List.NonEmpty as NonEmpty
68import qualified Streamly.Internal.Data.Array as Array
68import qualified Streamly.Internal.Data.Array as Array
69−import qualified Streamly.Internal.Data.Stream.IsStream as Stream
69+import qualified Streamly.Internal.Data.Stream as Stream
70+import qualified Streamly.Internal.Data.Stream.Concurrent as Stream
70import qualified Streamly.Unicode.Stream as Unicode
71import qualified Streamly.Unicode.Stream as Unicode
71
72
72#if defined(FILESYSTEM_EVENT_LINUX)
73#if defined(FILESYSTEM_EVENT_LINUX)
@@ -95,7 +96,7 @@ type EventChecker =
95 -> MVar () -- mvar to sync file system ops and the watch
96 -> MVar () -- mvar to sync file system ops and the watch
96 -> [(String, Event -> Bool)] -- expected events
97 -> [(String, Event -> Bool)] -- expected events
97 -> IO ()
98 -> IO ()
98−type EventWatcher = NonEmpty (Array Word8) -> Stream.SerialT IO Event.Event
99+type EventWatcher = NonEmpty (Array Word8) -> Stream.Stream IO Event.Event
99
100
100eventMatches :: Event -> (String, Event -> Bool) -> Bool
101eventMatches :: Event -> (String, Event -> Bool) -> Bool
101eventMatches ev (expectedPath, f) =
102eventMatches ev (expectedPath, f) =
@@ -193,7 +194,8 @@ driver checker symlinkStyle (desc, pre, ops, expected) =
193 -- with the events occurred after the watch is started.
194 -- with the events occurred after the watch is started.
194 let check = checker root target sync expected
195 let check = checker root target sync expected
195 fsOps = Stream.fromEffect $ runFSOps root sync
196 fsOps = Stream.fromEffect $ runFSOps root sync
197+ Stream.drain
196− Stream.drain $ Stream.fromEffect check `Stream.parallelFst` fsOps
198+ $ Stream.parListEagerFst [Stream.fromEffect check, fsOps]
197
199
198 runFSOps fp sync = do
200 runFSOps fp sync = do
199 -- We put the MVar before the event watcher starts to run but that does
201 -- We put the MVar before the event watcher starts to run but that does
test/Streamly/Test/Network/Inet/TCP.hs+5−4
@@ -22,11 +22,12 @@ import Streamly.Internal.Data.Stream (Stream)
22import Test.QuickCheck (Property)
22import Test.QuickCheck (Property)
23import Test.QuickCheck.Monadic (monadicIO, assert, run)
23import Test.QuickCheck.Monadic (monadicIO, assert, run)
24
24
25+import qualified Streamly.Data.Fold as Fold
26+import qualified Streamly.Data.Stream.Prelude as Stream
25import qualified Streamly.Internal.Data.Unfold as Unfold
27import qualified Streamly.Internal.Data.Unfold as Unfold
26import qualified Streamly.Internal.Network.Inet.TCP as TCP
28import qualified Streamly.Internal.Network.Inet.TCP as TCP
27import qualified Streamly.Internal.Network.Socket as Socket
29import qualified Streamly.Internal.Network.Socket as Socket
28import qualified Streamly.Internal.Unicode.Stream as Unicode
30import qualified Streamly.Internal.Unicode.Stream as Unicode
29−import qualified Streamly.Prelude as Stream
30
31
31import Test.Hspec
32import Test.Hspec
32import Test.Hspec.QuickCheck
33import Test.Hspec.QuickCheck
@@ -73,9 +74,9 @@ server
73 -> IO ()
74 -> IO ()
74server listener port sem handler = do
75server listener port sem handler = do
75 putMVar sem ()
76 putMVar sem ()
76− Stream.fromSerial (Stream.unfold listener port)
77+ Stream.unfold listener port
77− & (Stream.fromAsync . Stream.mapM (Socket.forSocketM handler))
78+ & Stream.mapM (Socket.forSocketM handler)
78− & Stream.drain
79+ & Stream.fold Fold.drain
79
80
80remoteAddr :: (Word8,Word8,Word8,Word8)
81remoteAddr :: (Word8,Word8,Word8,Word8)
81remoteAddr = (127, 0, 0, 1)
82remoteAddr = (127, 0, 0, 1)
test/Streamly/Test/Network/Socket.hs+5−4
@@ -22,10 +22,11 @@ import Streamly.Internal.Data.Stream (Stream)
22import Test.QuickCheck (Property)
22import Test.QuickCheck (Property)
23import Test.QuickCheck.Monadic (monadicIO, assert, run)
23import Test.QuickCheck.Monadic (monadicIO, assert, run)
24
24
25+import qualified Streamly.Data.Fold as Fold
26+import qualified Streamly.Data.Stream.Prelude as Stream
25import qualified Streamly.Internal.Network.Inet.TCP as TCP
27import qualified Streamly.Internal.Network.Inet.TCP as TCP
26import qualified Streamly.Internal.Network.Socket as Socket
28import qualified Streamly.Internal.Network.Socket as Socket
27import qualified Streamly.Internal.Unicode.Stream as Unicode
29import qualified Streamly.Internal.Unicode.Stream as Unicode
28−import qualified Streamly.Prelude as Stream
29
30
30import Test.Hspec
31import Test.Hspec
31import Test.Hspec.QuickCheck
32import Test.Hspec.QuickCheck
@@ -86,9 +87,9 @@ basePort = 64000
86server :: PortNumber -> MVar () -> (Socket -> IO ()) -> IO ()
87server :: PortNumber -> MVar () -> (Socket -> IO ()) -> IO ()
87server port sem handler = do
88server port sem handler = do
88 putMVar sem ()
89 putMVar sem ()
89− Stream.fromSerial (Stream.unfold TCP.acceptorOnPort port)
90+ Stream.unfold TCP.acceptorOnPort port
90− & Stream.fromAsync . Stream.mapM (Socket.forSocketM handler)
91+ & Stream.mapM (Socket.forSocketM handler)
91− & Stream.drain
92+ & Stream.fold Fold.drain
92
93
93remoteAddr :: (Word8,Word8,Word8,Word8)
94remoteAddr :: (Word8,Word8,Word8,Word8)
94remoteAddr = (127, 0, 0, 1)
95remoteAddr = (127, 0, 0, 1)
test/Streamly/Test/Prelude/Serial.hs+35−32
@@ -1,4 +1,5 @@
1{-# OPTIONS_GHC -Wno-deprecations #-}
1{-# OPTIONS_GHC -Wno-deprecations #-}
2+{-# Language TypeApplications #-}
2
3
3-- |
4-- |
4-- Module : Streamly.Test.Prelude.Serial
5-- Module : Streamly.Test.Prelude.Serial
@@ -48,8 +49,10 @@ import qualified Streamly.Data.Stream.Prelude as S
48import qualified Streamly.Internal.Data.Fold as FL
49import qualified Streamly.Internal.Data.Fold as FL
49import qualified Streamly.Internal.Data.Unfold as UF
50import qualified Streamly.Internal.Data.Unfold as UF
50import qualified Streamly.Internal.Data.Stream as IS
51import qualified Streamly.Internal.Data.Stream as IS
52+import qualified Streamly.Internal.Data.Stream.StreamK as K
51import qualified Streamly.Data.Array as A
53import qualified Streamly.Data.Array as A
52import qualified Streamly.Internal.Data.Parser as Parser
54import qualified Streamly.Internal.Data.Parser as Parser
55+import qualified Streamly.Prelude as SP
53
56
54import Streamly.Internal.Data.Time.Units
57import Streamly.Internal.Data.Time.Units
55 (AbsTime, NanoSecond64(..), toRelTime64, diffAbsTime64)
58 (AbsTime, NanoSecond64(..), toRelTime64, diffAbsTime64)
@@ -90,8 +93,8 @@ groupsByRolling :: Monad m =>
90groupsByRolling cmp f m =
93groupsByRolling cmp f m =
91 S.catRights $ S.parseMany (Parser.groupByRolling cmp f) m
94 S.catRights $ S.parseMany (Parser.groupByRolling cmp f) m
92
95
93−drainWhile :: Monad m => (a -> Bool) -> S.Stream m a -> m ()
96+drainWhile :: Monad m => (a -> Bool) -> SerialT m a -> m ()
94−drainWhile p = S.fold FL.drain . S.takeWhile p
97+drainWhile p m = SP.fold FL.drain $ SP.takeWhile p m
95
98
96drainMapM :: Monad m => (a -> m b) -> S.Stream m a -> m ()
99drainMapM :: Monad m => (a -> m b) -> S.Stream m a -> m ()
97drainMapM f = S.fold (FL.drainMapM f)
100drainMapM f = S.fold (FL.drainMapM f)
@@ -427,12 +430,12 @@ associativityCheck desc t = prop desc assocCheckProp
427 assocCheckProp :: [Int] -> [Int] -> [Int] -> Property
430 assocCheckProp :: [Int] -> [Int] -> [Int] -> Property
428 assocCheckProp xs ys zs =
431 assocCheckProp xs ys zs =
429 monadicIO $ do
432 monadicIO $ do
430− let xStream = S.fromList xs
433+ let xStream = SP.fromList xs
431− yStream = S.fromList ys
434+ yStream = SP.fromList ys
432− zStream = S.fromList zs
435+ zStream = SP.fromList zs
433 infixAssocstream <-
436 infixAssocstream <-
434− run $ toList $ t $ xStream `serial` yStream `serial` zStream
437+ run $ SP.toList $ t $ xStream `serial` yStream `serial` zStream
435− assocStream <- run $ toList $ t $ xStream <> yStream <> zStream
438+ assocStream <- run $ SP.toList $ t $ xStream <> yStream <> zStream
436 listEquals (==) infixAssocstream assocStream
439 listEquals (==) infixAssocstream assocStream
437
440
438max_length :: Int
441max_length :: Int
@@ -540,7 +543,7 @@ foldIterateM =
540sortBy :: Property
543sortBy :: Property
541sortBy = forAll (listOf (chooseInt (0, max_length))) $ \lst -> monadicIO $ do
544sortBy = forAll (listOf (chooseInt (0, max_length))) $ \lst -> monadicIO $ do
542 let s1 = sort lst
545 let s1 = sort lst
543− s2 <- toList $ IS.sortBy compare $ S.fromList lst
546+ s2 <- toList $ K.toStream (K.sortBy compare $ K.fromStream $ S.fromList lst)
544 assert $ s1 == s2
547 assert $ s1 == s2
545
548
546moduleName :: String
549moduleName :: String
@@ -560,15 +563,15 @@ main = hspec
560 <> [("maxBuffer -1", fromSerial . maxBuffer (-1))]
563 <> [("maxBuffer -1", fromSerial . maxBuffer (-1))]
561#endif
564#endif
562 let toListSerial :: SerialT IO a -> IO [a]
565 let toListSerial :: SerialT IO a -> IO [a]
563− toListSerial = toList . fromSerial
566+ toListSerial = SP.toList
564
567
565 describe "Runners" $ do
568 describe "Runners" $ do
566 -- XXX use an IORef to store and check the side effects
569 -- XXX use an IORef to store and check the side effects
567 it "simple serially" $
570 it "simple serially" $
568− (S.fold FL.drain . fromSerial)
571+ (SP.fold FL.drain . fromSerial)
569 (return (0 :: Int)) `shouldReturn` ()
572 (return (0 :: Int)) `shouldReturn` ()
570 it "simple serially with IO" $
573 it "simple serially with IO" $
571− (S.fold FL.drain . fromSerial)
574+ (S.fold FL.drain)
572 (S.fromEffect $ putStrLn "hello") `shouldReturn` ()
575 (S.fromEffect $ putStrLn "hello") `shouldReturn` ()
573
576
574 describe "Empty" $
577 describe "Empty" $
@@ -601,8 +604,8 @@ main = hspec
601 serialOps $ prop "serially unfoldr" . constructWithUnfoldr id
604 serialOps $ prop "serially unfoldr" . constructWithUnfoldr id
602 serialOps $ prop "serially fromPure" . constructWithFromPure id
605 serialOps $ prop "serially fromPure" . constructWithFromPure id
603 serialOps $ prop "serially fromEffect" . constructWithFromEffect id
606 serialOps $ prop "serially fromEffect" . constructWithFromEffect id
604− serialOps $ prop "serially cons" . constructWithCons S.cons
607+ serialOps $ prop "serially cons" . constructWithCons SP.cons
605− serialOps $ prop "serially consM" . constructWithConsM S.consM id
608+ serialOps $ prop "serially consM" . constructWithConsM SP.consM id
606
609
607 describe "From Generators" $ do
610 describe "From Generators" $ do
608 prop "unfold" unfold
611 prop "unfold" unfold
@@ -610,7 +613,7 @@ main = hspec
610 describe "Simple Operations" $ serialOps simpleOps
613 describe "Simple Operations" $ serialOps simpleOps
611
614
612 describe "Functor operations" $ do
615 describe "Functor operations" $ do
613− serialOps $ functorOps S.fromFoldable "serially" (==)
616+ serialOps $ functorOps (SP.fromFoldable) "serially" (==)
614 serialOps $ functorOps folded "serially folded" (==)
617 serialOps $ functorOps folded "serially folded" (==)
615
618
616 describe "Monoid operations" $ do
619 describe "Monoid operations" $ do
@@ -639,17 +642,17 @@ main = hspec
639 -- The tests using sorted equality are weaker tests
642 -- The tests using sorted equality are weaker tests
640 -- We need to have stronger unit tests for all those
643 -- We need to have stronger unit tests for all those
641 -- XXX applicative with three arguments
644 -- XXX applicative with three arguments
642− serialOps $ applicativeOps S.fromFoldable "serially" (==)
645+ serialOps $ applicativeOps (SP.fromFoldable) "serially" (==)
643 serialOps $ applicativeOps folded "serially folded" (==)
646 serialOps $ applicativeOps folded "serially folded" (==)
644− serialOps $ applicativeOps1 S.fromFoldable "serially" (==)
647+ serialOps $ applicativeOps1 (SP.fromFoldable) "serially" (==)
645− serialOps $ applicativeOps1 S.fromFoldable "serially folded" (==)
648+ serialOps $ applicativeOps1 (SP.fromFoldable) "serially folded" (==)
646
649
647 -- XXX add tests for indexed/indexedR
650 -- XXX add tests for indexed/indexedR
648 describe "Zip operations" $ do
651 describe "Zip operations" $ do
649 -- We test only the serial zip with serial streams and the parallel
652 -- We test only the serial zip with serial streams and the parallel
650 -- stream, because the rate setting in these streams can slow down
653 -- stream, because the rate setting in these streams can slow down
651 -- zipAsync.
654 -- zipAsync.
652− serialOps $ prop "zip monadic serially" . zipMonadic S.fromFoldable (==)
655+ serialOps $ prop "zip monadic serially" . zipMonadic (SP.fromFoldable) (==)
653 serialOps $ prop "zip monadic serially folded" . zipMonadic folded (==)
656 serialOps $ prop "zip monadic serially folded" . zipMonadic folded (==)
654
657
655 -- XXX add merge tests like zip tests
658 -- XXX add merge tests like zip tests
@@ -658,15 +661,15 @@ main = hspec
658 -- describe "Merge operations" $ do
661 -- describe "Merge operations" $ do
659
662
660 describe "Monad operations" $ do
663 describe "Monad operations" $ do
661− serialOps $ prop "serially monad then" . monadThen S.fromFoldable (==)
664+ serialOps $ prop "serially monad then" . monadThen (SP.fromFoldable) (==)
662 serialOps $ prop "serially monad then folded" . monadThen folded (==)
665 serialOps $ prop "serially monad then folded" . monadThen folded (==)
663− serialOps $ prop "serially monad bind" . monadBind S.fromFoldable (==)
666+ serialOps $ prop "serially monad bind" . monadBind (SP.fromFoldable) (==)
664 serialOps $ prop "serially monad bind folded" . monadBind folded (==)
667 serialOps $ prop "serially monad bind folded" . monadBind folded (==)
665
668
666 describe "Stream transform and combine operations" $ do
669 describe "Stream transform and combine operations" $ do
667− serialOps $ transformCombineOpsCommon S.fromFoldable "serially" (==)
670+ serialOps $ transformCombineOpsCommon (SP.fromFoldable) "serially" (==)
668 serialOps $ transformCombineOpsCommon folded "serially" (==)
671 serialOps $ transformCombineOpsCommon folded "serially" (==)
669− serialOps $ transformCombineOpsOrdered S.fromFoldable "serially" (==)
672+ serialOps $ transformCombineOpsOrdered (SP.fromFoldable) "serially" (==)
670 serialOps $ transformCombineOpsOrdered folded "serially" (==)
673 serialOps $ transformCombineOpsOrdered folded "serially" (==)
671
674
672#ifdef DEVBUILD
675#ifdef DEVBUILD
@@ -678,19 +681,19 @@ main = hspec
678 -- Just some basic sanity tests for now
681 -- Just some basic sanity tests for now
679 let input = [[1,1] :: [Int],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8]]
682 let input = [[1,1] :: [Int],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8]]
680 mustBe g inp out =
683 mustBe g inp out =
681− toList (S.mergeMapWith g S.fromList (S.fromList inp))
684+ toList (K.toStream (K.mergeMapWith g K.fromList (K.fromList inp)))
682 `shouldReturn` out
685 `shouldReturn` out
683 in do
686 in do
684 it "concatPairsWith serial"
687 it "concatPairsWith serial"
685− $ mustBe S.append input [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
688+ $ mustBe K.append input [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
686 it "concatPairsWith wSerial"
689 it "concatPairsWith wSerial"
687− $ mustBe S.interleave input [1,5,3,7,2,6,4,8,1,5,3,7,2,6,4,8]
690+ $ mustBe K.interleave input [1,5,3,7,2,6,4,8,1,5,3,7,2,6,4,8]
688 it "concatPairsWith mergeBy sorted"
691 it "concatPairsWith mergeBy sorted"
689 $ mustBe
692 $ mustBe
690− (S.mergeBy compare) input [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
693+ (K.mergeBy compare) input [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
691 it "concatPairsWith mergeBy reversed"
694 it "concatPairsWith mergeBy reversed"
692 $ mustBe
695 $ mustBe
693− (S.mergeBy compare)
696+ (K.mergeBy compare)
694 (reverse input)
697 (reverse input)
695 [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
698 [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
696 prop "sortBy" sortBy
699 prop "sortBy" sortBy
@@ -699,9 +702,9 @@ main = hspec
699 groupSplitOps "serially"
702 groupSplitOps "serially"
700
703
701 describe "Stream elimination operations" $ do
704 describe "Stream elimination operations" $ do
702− serialOps $ eliminationOps S.fromFoldable "serially"
705+ serialOps $ eliminationOps (SP.fromFoldable) "serially"
703 serialOps $ eliminationOps folded "serially folded"
706 serialOps $ eliminationOps folded "serially folded"
704− serialOps $ eliminationOpsWord8 S.fromFoldable "serially"
707+ serialOps $ eliminationOpsWord8 (SP.fromFoldable) "serially"
705 serialOps $ eliminationOpsWord8 folded "serially folded"
708 serialOps $ eliminationOpsWord8 folded "serially folded"
706 serialOps $ \t ->
709 serialOps $ \t ->
707 prop "drainWhile (> 0)" $ \n ->
710 prop "drainWhile (> 0)" $ \n ->
@@ -711,15 +714,15 @@ main = hspec
711 ioRef <- run $ newIORef ([] :: [Int])
714 ioRef <- run $ newIORef ([] :: [Int])
712 run $
715 run $
713 drainWhile (> 0) . t $
716 drainWhile (> 0) . t $
714− S.mapM (\a -> modifyIORef' ioRef (a :) >> return a) $
717+ SP.mapM (\a -> modifyIORef' ioRef (a :) >> return a) $
715− S.fromList xs
718+ SP.fromList xs
716 strm <- run $ readIORef ioRef
719 strm <- run $ readIORef ioRef
717 listEquals (==) (reverse strm) (takeWhile (> 0) xs)
720 listEquals (==) (reverse strm) (takeWhile (> 0) xs)
718
721
719 -- XXX Add a test where we chain all transformation APIs and make sure that
722 -- XXX Add a test where we chain all transformation APIs and make sure that
720 -- the state is being passed through all of them.
723 -- the state is being passed through all of them.
721 describe "Stream serial elimination operations" $ do
724 describe "Stream serial elimination operations" $ do
722− serialOps $ eliminationOpsOrdered S.fromFoldable "serially"
725+ serialOps $ eliminationOpsOrdered (SP.fromFoldable) "serially"
723 serialOps $ eliminationOpsOrdered folded "serially folded"
726 serialOps $ eliminationOpsOrdered folded "serially folded"
724
727
725 describe "Tests for S.groupsBy" groupingOps
728 describe "Tests for S.groupsBy" groupingOps
test/Streamly/Test/Unicode/Stream.hs+29−27
@@ -19,9 +19,9 @@ import Test.QuickCheck
19import Test.QuickCheck.Monadic (run, monadicIO, assert)
19import Test.QuickCheck.Monadic (run, monadicIO, assert)
20
20
21import qualified Streamly.Data.Array as A
21import qualified Streamly.Data.Array as A
22+import qualified Streamly.Data.Stream as Stream
22import qualified Streamly.Internal.Data.Stream.Chunked as AS
23import qualified Streamly.Internal.Data.Stream.Chunked as AS
23−import qualified Streamly.Prelude as S
24+import qualified Streamly.Internal.Data.Stream.StreamD as Stream
24−import qualified Streamly.Internal.Data.Stream.IsStream as S
25import qualified Streamly.Unicode.Stream as SS
25import qualified Streamly.Unicode.Stream as SS
26import qualified Streamly.Internal.Unicode.Stream as IUS
26import qualified Streamly.Internal.Unicode.Stream as IUS
27import qualified Streamly.Internal.Unicode.Array as IUA
27import qualified Streamly.Internal.Unicode.Array as IUA
@@ -50,8 +50,8 @@ propDecodeEncodeId' :: Property
50propDecodeEncodeId' =
50propDecodeEncodeId' =
51 forAll genUnicode $ \list ->
51 forAll genUnicode $ \list ->
52 monadicIO $ do
52 monadicIO $ do
53− let wrds = SS.encodeUtf8' $ S.fromList list
53+ let wrds = SS.encodeUtf8' $ Stream.fromList list
54− chrs <- S.toList $ SS.decodeUtf8' wrds
54+ chrs <- run $ Stream.toList $ SS.decodeUtf8' wrds
55 assert (chrs == list)
55 assert (chrs == list)
56
56
57-- XXX need to use invalid characters
57-- XXX need to use invalid characters
@@ -59,16 +59,16 @@ propDecodeEncodeId :: Property
59propDecodeEncodeId =
59propDecodeEncodeId =
60 forAll genUnicode $ \list ->
60 forAll genUnicode $ \list ->
61 monadicIO $ do
61 monadicIO $ do
62− let wrds = SS.encodeUtf8 $ S.fromList list
62+ let wrds = SS.encodeUtf8 $ Stream.fromList list
63− chrs <- S.toList $ SS.decodeUtf8 wrds
63+ chrs <- Stream.toList $ SS.decodeUtf8 wrds
64 assert (chrs == list)
64 assert (chrs == list)
65
65
66propDecodeEncodeIdArrays :: Property
66propDecodeEncodeIdArrays :: Property
67propDecodeEncodeIdArrays =
67propDecodeEncodeIdArrays =
68 forAll genUnicode $ \list ->
68 forAll genUnicode $ \list ->
69 monadicIO $ do
69 monadicIO $ do
70− let wrds = S.arraysOf 8 $ SS.encodeUtf8' $ S.fromList list
70+ let wrds = Stream.arraysOf 8 $ SS.encodeUtf8' $ Stream.fromList list
71− chrs <- S.toList $ IUS.decodeUtf8Arrays wrds
71+ chrs <- Stream.toList $ IUS.decodeUtf8Arrays wrds
72 assert (chrs == list)
72 assert (chrs == list)
73
73
74unicodeTestData :: [Char]
74unicodeTestData :: [Char]
@@ -82,8 +82,10 @@ propASCIIToLatin1 =
82 forAll (choose (1, 1000)) $ \len ->
82 forAll (choose (1, 1000)) $ \len ->
83 forAll (vectorOf len arbitraryASCIIChar) $ \list ->
83 forAll (vectorOf len arbitraryASCIIChar) $ \list ->
84 monadicIO $ do
84 monadicIO $ do
85− let wrds = SS.decodeLatin1 $ SS.encodeLatin1 $ S.fromList list
85+ let wrds = SS.decodeLatin1
86+ $ SS.encodeLatin1
87+ $ Stream.fromList list
86− lst <- run $ S.toList wrds
88+ lst <- run $ Stream.toList wrds
87 assert (list == lst)
89 assert (list == lst)
88
90
89propUnicodeToLatin1 :: Property
91propUnicodeToLatin1 :: Property
@@ -92,8 +94,8 @@ propUnicodeToLatin1 =
92 let wrds =
94 let wrds =
93 SS.decodeLatin1
95 SS.decodeLatin1
94 $ SS.encodeLatin1
96 $ SS.encodeLatin1
95− $ S.fromList unicodeTestData
97+ $ Stream.fromList unicodeTestData
96− lst <- run $ S.toList wrds
98+ lst <- run $ Stream.toList wrds
97 assert (latin1TestData == lst)
99 assert (latin1TestData == lst)
98
100
99propUnicodeToLatin1' :: Property
101propUnicodeToLatin1' :: Property
@@ -102,28 +104,28 @@ propUnicodeToLatin1' =
102 let wrds =
104 let wrds =
103 SS.decodeLatin1
105 SS.decodeLatin1
104 $ SS.encodeLatin1'
106 $ SS.encodeLatin1'
105− $ S.fromList unicodeTestData
107+ $ Stream.fromList unicodeTestData
106− lst <- run $ S.toList wrds
108+ lst <- run $ Stream.toList wrds
107 assert (latin1TestData == lst)
109 assert (latin1TestData == lst)
108
110
109testLines :: Property
111testLines :: Property
110testLines =
112testLines =
111 forAll genUnicode $ \list ->
113 forAll genUnicode $ \list ->
112 monadicIO $ do
114 monadicIO $ do
113− xs <- S.toList
115+ xs <- Stream.toList
114− $ S.map A.toList
116+ $ fmap A.toList
115 $ IUA.lines
117 $ IUA.lines
116− $ S.fromList list
118+ $ Stream.fromList list
117 assert (xs == lines list)
119 assert (xs == lines list)
118
120
119testLinesArray :: Property
121testLinesArray :: Property
120testLinesArray =
122testLinesArray =
121 forAll genWord8 $ \list ->
123 forAll genWord8 $ \list ->
122 monadicIO $ do
124 monadicIO $ do
123− xs <- S.toList
125+ xs <- Stream.toList
124− $ S.map A.toList
126+ $ fmap A.toList
125 $ AS.splitOnSuffix 10
127 $ AS.splitOnSuffix 10
126− $ S.fromPure (A.fromList list)
128+ $ Stream.fromPure (A.fromList list)
127 assert (xs == map (map (fromIntegral . ord))
129 assert (xs == map (map (fromIntegral . ord))
128 (lines (map (chr . fromIntegral) list)))
130 (lines (map (chr . fromIntegral) list)))
129
131
@@ -131,20 +133,20 @@ testWords :: Property
131testWords =
133testWords =
132 forAll genUnicode $ \list ->
134 forAll genUnicode $ \list ->
133 monadicIO $ do
135 monadicIO $ do
134− xs <- S.toList
136+ xs <- Stream.toList
135− $ S.map A.toList
137+ $ Stream.map A.toList
136 $ IUA.words
138 $ IUA.words
137− $ S.fromList list
139+ $ Stream.fromList list
138 assert (xs == words list)
140 assert (xs == words list)
139
141
140testUnlines :: Property
142testUnlines :: Property
141testUnlines =
143testUnlines =
142 forAll genUnicode $ \list ->
144 forAll genUnicode $ \list ->
143 monadicIO $ do
145 monadicIO $ do
144− xs <- S.toList
146+ xs <- Stream.toList
145 $ IUA.unlines
147 $ IUA.unlines
146 $ IUA.lines
148 $ IUA.lines
147− $ S.fromList list
149+ $ Stream.fromList list
148 assert (xs == unlines (lines list))
150 assert (xs == unlines (lines list))
149
151
150testUnwords :: Property
152testUnwords :: Property
@@ -152,10 +154,10 @@ testUnwords =
152 forAll genUnicode $ \list ->
154 forAll genUnicode $ \list ->
153 monadicIO $ do
155 monadicIO $ do
154 xs <- run
156 xs <- run
155− $ S.toList
157+ $ Stream.toList
156 $ IUA.unwords
158 $ IUA.unwords
157 $ IUA.words
159 $ IUA.words
158− $ S.fromList list
160+ $ Stream.fromList list
159 assert (xs == unwords (words list))
161 assert (xs == unwords (words list))
160
162
161moduleName :: String
163moduleName :: String
test/streamly-tests.cabal+2
@@ -219,6 +219,8 @@ test-suite Data.List
219 type: exitcode-stdio-1.0
219 type: exitcode-stdio-1.0
220 main-is: Streamly/Test/Data/List.hs
220 main-is: Streamly/Test/Data/List.hs
221 cpp-options: -DUSE_STREAMLY_LIST
221 cpp-options: -DUSE_STREAMLY_LIST
222+ if !flag(dev)
223+ buildable: False
222
224
223test-suite Data.List.Base
225test-suite Data.List.Base
224 import: test-options
226 import: test-options