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

FoldableTests are not testing sequence_/traverse_ #2679

Open
johnynek opened this issue Jan 1, 2019 · 1 comment
Open

FoldableTests are not testing sequence_/traverse_ #2679

johnynek opened this issue Jan 1, 2019 · 1 comment

Comments

@johnynek
Copy link
Contributor

johnynek commented Jan 1, 2019

see: typelevel/cats-collections@4812b86#diff-1f70710e148c78ab48fdd3687d6ecd0bR201

I had to add that to get full test coverage.

We could have a law that: fa.sequence_ == fa.foldMap(identity) where we construct the natural Monoid[G[Unit]] for an Applicative.

More generally, I think we should have a practice that each instance matches an instance with only the abstract methods proxied through. This guarantees that all the other methods are only override for efficiency, not to change any semantics. If we made sure to test this way we could simplify our tests since we only need to write laws on the abstract methods, and then the additional law that we match the proxied instance.

@peterneyens
Copy link
Collaborator

we should have a practice that each instance matches an instance with only the abstract methods proxied through

See also #1684.

I tried quite a while ago to generate these sort of tests with scalameta, but I stopped I think when I had to deal with inheritance (for example Apply where we also need Functor#map).

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

No branches or pull requests

2 participants