Skip to content

Commit

Permalink
Add Test that actually hits the implicated ApplicativeError instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Jacobowitz committed Aug 26, 2017
1 parent 1836c07 commit d62e1e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/src/main/scala/cats/Parallel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ trait Parallel[M[_], F[_]] {

object Parallel extends ParallelArityFunctions {

def apply[M[_], F[_]](implicit P: Parallel[M, F]): Parallel[M, F] = P

/**
* Like `Traverse[A].sequence`, but uses the applicative instance
* corresponding to the Parallel instance instead.
Expand Down
21 changes: 19 additions & 2 deletions tests/src/test/scala/cats/tests/ParallelTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package cats

import cats.data._
import cats.tests.CatsSuite
import org.scalatest.FunSuite
import cats.laws.discipline.{ApplicativeErrorTests, ParallelTests => ParallelTypeclassTests}
import cats.laws.discipline.eq._
import cats.laws.discipline.arbitrary._
import org.scalacheck.Arbitrary
import org.typelevel.discipline.scalatest.Discipline

class ParallelTests extends CatsSuite {
class ParallelTests extends CatsSuite with ApplicativeErrorForEitherTest {


test("ParTraversing Either should accumulate errors") {
Expand Down Expand Up @@ -68,5 +70,20 @@ class ParallelTests extends CatsSuite {
checkAll("Parallel[KlesliT[M, ?], Nested[F, Option, ?]]", ParallelTypeclassTests[Kleisli[Either[String, ?], Int, ?], Kleisli[Validated[String, ?], Int, ?], Int].parallel)
}

checkAll("ApplicativeError[Either[String, Int]]", ApplicativeErrorTests[Either[String, ?], String].applicativeError[Int, Int, Int])

}

trait ApplicativeErrorForEitherTest extends FunSuite with Discipline {
import cats.instances.parallel._
import cats.instances.either._
import cats.instances.string._
import cats.instances.int._
import cats.instances.unit._
import cats.instances.tuple._

implicit def eqV[A: Eq,B: Eq]: Eq[Validated[A, B]] = cats.data.Validated.catsDataEqForValidated



checkAll("ApplicativeError[Validated[String, Int]]", ApplicativeErrorTests[Validated[String, ?], String].applicativeError[Int, Int, Int])
}

0 comments on commit d62e1e2

Please sign in to comment.