@@ -173,6 +173,29 @@ constructWithIterateM op len =
173173 streamEffect <- run $ readIORef mvl
174174 listEquals (==) streamEffect list
175175
176+constructWithFromIndices ::
177+ IsStream t => (t IO Int -> SerialT IO Int) -> Word8 -> Property
178+constructWithFromIndices op len =
179+ withMaxSuccess maxTestCount $
180+ monadicIO $ do
181+ stream <-
182+ run $ (S.toList . op . S.take (fromIntegral len)) (S.fromIndices id)
183+ let list = take (fromIntegral len) (iterate (+ 1) 0)
184+ listEquals (==) stream list
185+
186+constructWithFromIndicesM ::
187+ IsStream t => (t IO Int -> SerialT IO Int) -> Word8 -> Property
188+constructWithFromIndicesM op len =
189+ withMaxSuccess maxTestCount $
190+ monadicIO $ do
191+ mvl <- run (newIORef [] :: IO (IORef [Int]))
192+ let addIndex mv i = modifyIORef' mv (++ [i]) >> return i
193+ list = take (fromIntegral len) (iterate (+ 1) 0)
194+ run $
195+ S.drain . op $
196+ S.take (fromIntegral len) $ S.fromIndicesM (addIndex mvl)
197+ streamEffect <- run $ readIORef mvl
198+ listEquals (==) streamEffect list
176199
177200-------------------------------------------------------------------------------
178201-- Concurrent generation
@@ -1017,6 +1040,10 @@ main = hspec
10171040 -- parallelOps $ prop "parallely iterateM" parallely . onstructWithIterate
10181041 -- XXX add tests for fromIndices
10191042
1043+ serialOps $ prop "serially fromIndices" . constructWithFromIndices
1044+
1045+ serialOps $ prop "serially fromIndicesM" . constructWithFromIndicesM
1046+
10201047 describe "Functor operations" $ do
10211048 serialOps $ functorOps S.fromFoldable "serially" (==)
10221049 serialOps $ functorOps folded "serially folded" (==)