@@ -173,6 +173,29 @@ constructWithIterateM op len =
173 streamEffect <- run $ readIORef mvl
173 streamEffect <- run $ readIORef mvl
174 listEquals (==) streamEffect list
174 listEquals (==) streamEffect list
176+constructWithFromIndices ::
177+ IsStream t => (t IO Int -> SerialT IO Int) -> Word8 -> Property
178+constructWithFromIndices op len =
179+ withMaxSuccess maxTestCount $
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
186+constructWithFromIndicesM ::
187+ IsStream t => (t IO Int -> SerialT IO Int) -> Word8 -> Property
188+constructWithFromIndicesM op len =
189+ withMaxSuccess maxTestCount $
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)
196+ S.take (fromIntegral len) $ S.fromIndicesM (addIndex mvl)
197+ streamEffect <- run $ readIORef mvl
198+ listEquals (==) streamEffect list
177-------------------------------------------------------------------------------
200-------------------------------------------------------------------------------
178-- Concurrent generation
201-- Concurrent generation
@@ -1017,6 +1040,10 @@ main = hspec
1017 -- parallelOps $ prop "parallely iterateM" parallely . onstructWithIterate
1040 -- parallelOps $ prop "parallely iterateM" parallely . onstructWithIterate
1018 -- XXX add tests for fromIndices
1041 -- XXX add tests for fromIndices
1043+ serialOps $ prop "serially fromIndices" . constructWithFromIndices
1045+ serialOps $ prop "serially fromIndicesM" . constructWithFromIndicesM
1020 describe "Functor operations" $ do
1047 describe "Functor operations" $ do
1021 serialOps $ functorOps S.fromFoldable "serially" (==)
1048 serialOps $ functorOps S.fromFoldable "serially" (==)
1022 serialOps $ functorOps folded "serially folded" (==)
1049 serialOps $ functorOps folded "serially folded" (==)