-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix issue in Reducible #1685
Fix issue in Reducible #1685
Conversation
👍 LGTM but maybe this is a sign that we should have a unit test for this :) |
@ceedubs point taken.... |
Codecov Report
@@ Coverage Diff @@
## master #1685 +/- ##
==========================================
+ Coverage 93.94% 93.96% +0.01%
==========================================
Files 241 241
Lines 4096 4091 -5
Branches 156 151 -5
==========================================
- Hits 3848 3844 -4
+ Misses 248 247 -1
Continue to review full report at Codecov.
|
I think in principle every method that is not a simple delegation should be covered. This chrome extension is really helpful in checking that. |
I think the problem here is that all the instances of It would be nice if we could somehow check the consistency (#1684) and benchmark (something we talked about in #1532, see #1532 (comment)) overridden and the default implementation of type class methods. |
How about we add a doctest to cover this and address the overrides test coverage in #1684? That way we can merge this fix sooner. |
@kailuowang, do you mean something like : scala> import cats.data.NonEmptyList
scala> import cats.implicits._
scala> val R = new NonEmptyReducible[NonEmptyList, List] {
| def split[A](nel: NonEmptyList[A]): (A, List[A]) = (nel.head, nel.tail)
| }
scala> val nel = NonEmptyList.of(1,2,3)
scala> R.get(nel, 1L)
res0: Option[Int] = Some(2)
scala> R.get(nel, 4L)
res1: Option[Int] = None |
@peterneyens yup. that would work. |
@@ -227,7 +227,7 @@ abstract class NonEmptyReducible[F[_], G[_]](implicit G: Foldable[G]) extends Re | |||
} | |||
|
|||
override def get[A](fa: F[A])(idx: Long): Option[A] = | |||
if (idx == 0L) Some(split(fa)._1) else G.get(split(fa)._2)(idx) | |||
if (idx == 0L) Some(split(fa)._1) else G.get(split(fa)._2)(idx - 1L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not actually tested according to codecov.
Can we write a test to explicitly exercise this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnynek done.
Failure in the test is due to the |
Merging with two sign-offs. |
courtesy of @ceedubs finding the bug.