on master help sign in
Fix bug in findIndices and add a regression test. Fixes #311.

- Update Changelog.

commita97e3f39fbb53d77c0fef7f50c6aaa8153403d6b authorPranay Sashank <pranaysashank@gmail.com> dateWed 20 Nov 2019, 16:58 (7 years ago) parent2c95037
3 files changed+12−1
Changelog.md+7 src/Streamly/Streams/StreamD.hs+1−1 test/Prop.hs+4
Changelog.md+7
@@ -1,3 +1,10 @@
1+## Unreleased
2+
3+### Bug Fixes
4+
5+* Fix a bug that caused `findIndices` to increment the index during
6+ a Skip condition.
7+
18## 0.7.0
29
310### Breaking changes
src/Streamly/Streams/StreamD.hs+1−1
@@ -960,7 +960,7 @@ findIndices p (Stream step state) = Stream step' (state, 0)
960960 r <- step (adaptState gst) st
961961 return $ case r of
962962 Yield x s -> if p x then Yield i (s, i+1) else Skip (s, i+1)
963− Skip s -> Skip (s, i+1)
963+ Skip s -> Skip (s, i)
964964 Stop -> Stop
965965
966966{-# INLINE toListRev #-}
test/Prop.hs+4
@@ -620,6 +620,10 @@ transformCombineOpsOrdered constr desc eq t = do
620620
621621 prop (desc <> " findIndices") $
622622 transform (findIndices odd) t (S.findIndices odd)
623+ prop (desc <> " findIndices . filter") $
624+ transform (findIndices odd . filter odd)
625+ t
626+ (S.findIndices odd . S.filter odd)
623627 prop (desc <> " elemIndices") $
624628 transform (elemIndices 0) t (S.elemIndices 0)
625629