Skip to content

Commit

Permalink
fix #1398
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jun 15, 2017
1 parent f6f4d25 commit f5cfd7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/scalaz/Foldable.scala
Expand Up @@ -253,8 +253,8 @@ trait Foldable[F[_]] { self =>
} {
case (x @ ((amin, amax, bmin, bmax)), a) =>
val b = f(a)
if (Order[B].order(b, bmin) == LT) (a, amax, b, bmax)
else if (Order[B].order(b, bmax) == GT) (amin, a, bmin, b)
if (Order[B].lessThanOrEqual(b, bmin)) (a, amax, b, bmax)
else if (Order[B].greaterThanOrEqual(b, bmax)) (amin, a, bmin, b)
else x
} map {
case (amin, amax, _, _) => (amin, amax)
Expand Down
8 changes: 6 additions & 2 deletions tests/src/test/scala/scalaz/FoldableTest.scala
Expand Up @@ -69,10 +69,14 @@ object FoldableTest extends SpecLite {
(xs extremaOf f) must_== (xs minimumOf f).tuple(xs maximumOf f)
}
"extremaBy" ! forAll {
(xs: List[Int]) =>
val f: Int => Double = 1D + _
(xs: List[Int], f: Int => Int) =>
(xs extremaBy f) must_== (xs minimumBy f).tuple(xs maximumBy f)
}
"extremaBy consistent with minimumBy/maximumBy" ! {
val xs = (1 to 6).toList
val f: Int => Int = _ % 3
(xs extremaBy f) must_== (xs minimumBy f).tuple(xs maximumBy f)
}

"distinct" ! forAll {
(xs: List[Int]) =>
Expand Down

0 comments on commit f5cfd7b

Please sign in to comment.