Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foldable.dropWhile_() is not working as advertised #563

Closed
weihsiu opened this issue Oct 6, 2015 · 1 comment · Fixed by #623
Closed

Foldable.dropWhile_() is not working as advertised #563

weihsiu opened this issue Oct 6, 2015 · 1 comment · Fixed by #623
Assignees

Comments

@weihsiu
Copy link

weihsiu commented Oct 6, 2015

this is what i get when using Foldable.dropWhile_() in the repl. the results do not conform with the spec.

scala> Foldable[List].dropWhile_(List(2, 4, 5))(_ % 2 == 0)
res46: List[Int] = List(2, 4, 5)

scala> // should return List(5)

scala> Foldable[List].dropWhile_(List(1, 2, 4, 5))(_ % 2 == 0)
res47: List[Int] = List(2, 4, 5)

scala> // should return List(1, 2, 4, 5)
@ceedubs
Copy link
Contributor

ceedubs commented Oct 6, 2015

Thanks for spotting this and creating an issue @weihsiu. The fix itself is pretty easy (adding a ! in the implementation). However when I went to make this fix, I noticed that this probably should have been caught by https://github.com/non/cats/blob/master/tests/src/test/scala/cats/tests/FoldableTests.scala#L32 but this FoldableCheck class isn't actually used anywhere. @non do you think those tests should be moved into the FoldableTests in the laws module? The Iterator requirement is a bit outside of the norm for law tests, but we should certainly add these sort of checks in one way or another. Another option is just using toList or toStreaming on the F[A] instance and checking for consistency instead of requiring an Iterator.

non added a commit that referenced this issue Nov 11, 2015
In addition to fixing this bug, the commit defines several
FoldableCheck tests for various types that have foldable
instances.

Finally, the commit adds takeWhile_.

Fixes #563.
@non non self-assigned this Nov 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants