@@ -39,9 +39,11 @@ oddScan =
3939 Scanl. filtering odd
4040 & Scanl. lmapM (\ x -> threadDelay 100 >> pure x)
4141
42- parDistributeScanTest :: (Stream. Config -> Stream. Config ) -> IO ()
43- parDistributeScanTest concOpts = do
44- ref <- newIORef [evenScan, oddScan]
42+ parDistributeScanTestScanEnd :: (Stream. Config -> Stream. Config ) -> IO ()
43+ parDistributeScanTestScanEnd concOpts = do
44+ let streamLen = 1000
45+ evenLen = 100
46+ ref <- newIORef [Scanl. take evenLen evenScan, oddScan]
4547 let gen = atomicModifyIORef' ref (\ xs -> ([] , xs))
4648 inpList = [1 .. 1_000 ]
4749 inpStream = Stream. fromList inpList
@@ -50,6 +52,20 @@ parDistributeScanTest concOpts = do
5052 & Stream. concatMap Stream. fromList
5153 & Stream. catMaybes
5254 & Stream. fold Fold. toList
55+ sort res1 `shouldBe` [1 .. evenLen] ++ filter odd [(evenLen+ 1 ).. streamLen]
56+
57+ parDistributeScanTestStreamEnd :: (Stream. Config -> Stream. Config ) -> IO ()
58+ parDistributeScanTestStreamEnd concOpts = do
59+ let streamLen = 1000
60+ ref <- newIORef [evenScan, oddScan]
61+ let gen = atomicModifyIORef' ref (\ xs -> ([] , xs))
62+ inpList = [1 .. streamLen]
63+ inpStream = Stream. fromList inpList
64+ res1 <-
65+ Scanl. parDistributeScan concOpts gen inpStream
66+ & Stream. concatMap Stream. fromList
67+ & Stream. catMaybes
68+ & Stream. fold Fold. toList
5369 sort res1 `shouldBe` inpList
5470
5571main :: IO ()
@@ -59,5 +75,7 @@ main = hspec
5975 $ modifyMaxSuccess (const 10 )
6076#endif
6177 $ describe moduleName $ do
62- it " parDistributeScan (maxBuffer 1)"
63- $ parDistributeScanTest (Stream. maxBuffer 1 )
78+ it " parDistributeScan (stream end) (maxBuffer 1)"
79+ $ parDistributeScanTestStreamEnd (Stream. maxBuffer 1 )
80+ it " parDistributeScan (scan end)"
81+ $ parDistributeScanTestScanEnd (Stream. maxBuffer 1 )
0 commit comments