Skip to content

Commit

Permalink
Replace instance trait inheritance with imports in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Mar 3, 2020
1 parent a8e2c21 commit 8dd80e5
Show file tree
Hide file tree
Showing 122 changed files with 621 additions and 452 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package alleycats
package tests
package alleycats.tests

import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package alleycats
package tests
package alleycats.tests

import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package alleycats
package tests
package alleycats.tests

import alleycats.std.MapInstances
import cats._
import cats.instances.AllInstances
import cats.syntax.{AllSyntax, EqOps}
import cats.instances.all._
import cats.syntax.EqOps
import cats.tests.StrictCatsEquality
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import org.typelevel.discipline.scalatest.FunSuiteDiscipline
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Arbitrary.arbitrary
import org.scalatest.matchers.should.Matchers

import scala.util.{Failure, Success, Try}

/**
Expand All @@ -25,8 +23,6 @@ trait AlleycatsSuite
with ScalaCheckDrivenPropertyChecks
with FunSuiteDiscipline
with TestSettings
with AllInstances
with AllSyntax
with TestInstances
with StrictCatsEquality
with MapInstances {
Expand All @@ -35,7 +31,7 @@ trait AlleycatsSuite

// disable Eq syntax (by making `catsSyntaxEq` not implicit), since it collides
// with scalactic's equality
override def catsSyntaxEq[A: Eq](a: A): EqOps[A] = new EqOps[A](a)
def catsSyntaxEq[A: Eq](a: A): EqOps[A] = new EqOps[A](a)

implicit def EqIterable[A: Eq]: Eq[Iterable[A]] = Eq.by(_.toList)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package alleycats
package tests
package alleycats.tests

import cats.{Eval, Foldable}
import alleycats.std.all._
import cats.{Eval, Foldable}
import cats.instances.all._
import cats.laws.discipline.FoldableTests

class IterableTests extends AlleycatsSuite {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package alleycats.tests

import cats.laws.discipline.arbitrary._
import cats.laws.discipline.{SerializableTests, TraverseFilterTests}
import cats.Traverse
import cats.instances.all._
import cats.laws.discipline.{SerializableTests, TraverseFilterTests}
import cats.laws.discipline.arbitrary._

class MapSuite extends AlleycatsSuite {
checkAll("Traverse[Map[Int, *]]", SerializableTests.serializable(Traverse[Map[Int, *]]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package alleycats.tests

import alleycats.laws.discipline._
import alleycats.std.all._
import cats.Foldable
import cats.instances.all._
import cats.kernel.laws.discipline.SerializableTests
import cats.laws.discipline.arbitrary._
import cats.laws.discipline.TraverseFilterTests

import alleycats.std.all._
import cats.laws.discipline.arbitrary._

class SetSuite extends AlleycatsSuite {
checkAll("FlatMapRec[Set]", FlatMapRecTests[Set].tailRecM[Int])
Expand Down
6 changes: 4 additions & 2 deletions free/src/test/scala/cats/free/CofreeSuite.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cats
package free
package cats.free

import cats.{~>, Comonad, Eval, Id, Reducible, Traverse}
import cats.data.{NonEmptyList, OptionT}
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{ComonadTests, ReducibleTests, SerializableTests, TraverseTests}
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.syntax.list._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cats
package free
package cats.free

import cats.{~>, Contravariant}
import cats.arrow.FunctionK
import cats.tests.CatsSuite
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{ContravariantTests, SerializableTests}

import cats.tests.CatsSuite
import org.scalacheck.{Arbitrary}

class ContravariantCoyonedaSuite extends CatsSuite {
Expand Down
9 changes: 5 additions & 4 deletions free/src/test/scala/cats/free/CoyonedaSuite.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cats
package free
package cats.free

import cats.tests.CatsSuite
import cats.Functor
import cats.arrow.FunctionK
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{FunctorTests, SerializableTests}

import cats.tests.CatsSuite
import org.scalacheck.Arbitrary

class CoyonedaSuite extends CatsSuite {
Expand Down
12 changes: 7 additions & 5 deletions free/src/test/scala/cats/free/FreeApplicativeSuite.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cats
package free
package cats.free

import cats.tests.CatsSuite
import cats.{~>, Applicative, Apply, Id}
import cats.arrow.FunctionK
import cats.data.State
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{ApplicativeTests, SerializableTests}
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.data.State

import cats.syntax.all._
import cats.tests.CatsSuite
import org.scalacheck.{Arbitrary, Gen}

class FreeApplicativeSuite extends CatsSuite {
Expand Down
11 changes: 7 additions & 4 deletions free/src/test/scala/cats/free/FreeInvariantMonoidalSuite.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package cats
package tests
package cats.free

import cats.{Id, InvariantMonoidal}
import cats.arrow.FunctionK
import cats.free.FreeInvariantMonoidal
import cats.kernel.Eq
import cats.instances.all._
import cats.laws.discipline.{InvariantMonoidalTests, MiniInt, SerializableTests}
import cats.laws.discipline.arbitrary._
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import org.scalacheck.{Arbitrary, Gen}
import cats.syntax.all._
import cats.tests.BinCodecInvariantMonoidalSuite._
import cats.tests.CatsSuite
import org.scalacheck.{Arbitrary, Gen}

class FreeInvariantMonoidalSuite extends CatsSuite {
implicit def freeInvariantMonoidalArbitrary[F[_], A](implicit F: Arbitrary[F[A]],
Expand Down
10 changes: 6 additions & 4 deletions free/src/test/scala/cats/free/FreeSuite.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package cats
package free
package cats.free

import cats.{:<:, Foldable, Functor, Id, Monad, Traverse}
import cats.arrow.FunctionK
import cats.data.EitherK
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{DeferTests, FoldableTests, MonadTests, SerializableTests, TraverseTests}
import cats.laws.discipline.arbitrary.catsLawsArbitraryForFn0
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.syntax.all._
import cats.tests.CatsSuite

import org.scalacheck.{Arbitrary, Cogen, Gen}
import Arbitrary.arbFunction1
import org.scalacheck.Arbitrary.arbFunction1

class FreeSuite extends CatsSuite {
import FreeSuite._
Expand Down
6 changes: 3 additions & 3 deletions free/src/test/scala/cats/free/FreeTSuite.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cats
package free
package cats.free

import cats._
import cats.arrow.FunctionK
import cats.data._
import cats.instances.all._
import cats.laws.discipline._
import cats.syntax.all._
import cats.tests.CatsSuite
import cats.instances.option._
import org.scalacheck.{Arbitrary, Cogen, Gen}

class FreeTSuite extends CatsSuite {
Expand Down
9 changes: 5 additions & 4 deletions free/src/test/scala/cats/free/YonedaSuite.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cats
package free
package cats.free

import cats.tests.CatsSuite
import cats.Functor
import cats.instances.all._
import cats.kernel.Eq
import cats.laws.discipline.{FunctorTests, SerializableTests}

import cats.tests.CatsSuite
import org.scalacheck.Arbitrary

class YonedaSuite extends CatsSuite {
Expand Down
24 changes: 12 additions & 12 deletions js/src/test/scala/cats/tests/FutureTests.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package cats
package js
package tests
package cats.js.tests

import cats.kernel.laws.discipline.{MonoidTests => MonoidLawTests, SemigroupTests => SemigroupLawTests}
import cats.laws.discipline._
import cats.Comonad
import cats.instances.all._
import cats.js.instances.Await
import cats.js.instances.future.futureComonad
import cats.kernel.Eq
import cats.kernel.laws.discipline.{MonoidTests => MonoidLawTests, SemigroupTests => SemigroupLawTests}
import cats.laws.discipline._
import cats.laws.discipline.arbitrary._
import cats.syntax.all._
import cats.tests.{CatsSuite, ListWrapper}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.concurrent.duration._

import org.scalacheck.{Arbitrary, Cogen}
import org.scalacheck.Arbitrary.arbitrary
import cats.laws.discipline.arbitrary._
import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.concurrent.duration._

class FutureTests extends CatsSuite {
// Replaces Scala.js's `JSExecutionContext.runNow`, which is removed in 1.0.
Expand Down Expand Up @@ -46,7 +46,7 @@ class FutureTests extends CatsSuite {
implicit val throwableEq: Eq[Throwable] =
Eq.by[Throwable, String](_.toString)

implicit val comonad: Comonad[Future] = futureComonad(timeout)
val comonad: Comonad[Future] = futureComonad(timeout)

// Need non-fatal Throwables for Future recoverWith/handleError
implicit val nonFatalArbitrary: Arbitrary[Throwable] =
Expand All @@ -59,7 +59,7 @@ class FutureTests extends CatsSuite {
Cogen[Unit].contramap(_ => ())

checkAll("Future[Int]", MonadErrorTests[Future, Throwable].monadError[Int, Int, Int])
checkAll("Future[Int]", ComonadTests[Future].comonad[Int, Int, Int])
checkAll("Future[Int]", ComonadTests[Future](comonad).comonad[Int, Int, Int])
checkAll("Future", MonadTests[Future].monad[Int, Int, Int])

{
Expand Down
14 changes: 7 additions & 7 deletions jvm/src/test/scala/cats/tests/FutureSuite.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package cats
package jvm
package tests
package cats.jvm.tests

import cats.instances.all._
import cats.kernel.{Eq, Semigroup}
import cats.kernel.laws.discipline.{MonoidTests => MonoidLawTests, SemigroupTests => SemigroupLawTests}
import cats.laws.discipline._
import cats.laws.discipline.arbitrary._
import cats.syntax.all._
import cats.tests.{CatsSuite, ListWrapper}

import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import org.scalacheck.{Arbitrary, Cogen}
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.rng.Seed
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global

class FutureSuite extends CatsSuite {
val timeout = 3.seconds
Expand Down
9 changes: 3 additions & 6 deletions testkit/src/main/scala/cats/tests/Helpers.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package cats
package tests
package cats.tests

import cats.kernel._
import org.scalacheck.{Arbitrary, Cogen}
import Arbitrary.arbitrary

import cats.kernel.{CommutativeGroup, CommutativeMonoid, CommutativeSemigroup}
import cats.kernel.{Band, BoundedSemilattice, Semilattice}
import org.scalacheck.Arbitrary.arbitrary

/**
* Helpers provides new concrete types where we control exactly which
Expand Down
12 changes: 7 additions & 5 deletions tests/src/test/scala-2.12/cats/tests/NonEmptyStreamSuite.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cats
package tests
package cats.tests

import cats.{Comonad, Eval, Functor, Monad, NonEmptyTraverse, Now, Reducible, SemigroupK, Show}
import cats.data.{NonEmptyStream, OneAnd}
import cats.instances.stream._
import cats.instances.all._
import cats.kernel.Semigroup
import cats.kernel.laws.discipline.{EqTests, SemigroupTests}
import cats.laws.discipline.arbitrary._
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.laws.discipline._
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.laws.discipline.arbitrary._
import cats.syntax.all._

class NonEmptyStreamSuite extends CatsSuite {
// Lots of collections here.. telling ScalaCheck to calm down a bit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package cats
package tests
package cats.tests

trait ScalaVersionSpecificFoldableSuite
trait ScalaVersionSpecificParallelSuite
Expand Down
8 changes: 5 additions & 3 deletions tests/src/test/scala-2.13+/cats/tests/ArraySeqSuite.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cats
package tests
package cats.tests

import cats.{Align, Alternative, CoflatMap, Monad, MonoidK, Traverse, TraverseFilter}
import cats.instances.all._
import cats.kernel.{Eq, Hash, Monoid, Order, PartialOrder}
import cats.kernel.laws.discipline.{EqTests, HashTests, MonoidTests, OrderTests, PartialOrderTests}
import cats.laws.discipline.{
AlignTests,
Expand All @@ -12,7 +14,7 @@ import cats.laws.discipline.{
TraverseTests
}
import cats.laws.discipline.arbitrary._

import cats.syntax.all._
import scala.collection.immutable.ArraySeq

class ArraySeqSuite extends CatsSuite {
Expand Down
8 changes: 5 additions & 3 deletions tests/src/test/scala-2.13+/cats/tests/LazyListSuite.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cats
package tests
package cats.tests

import cats.{Align, Alternative, CoflatMap, Monad, Semigroupal, Traverse, TraverseFilter}
import cats.data.ZipLazyList
import cats.instances.all._
import cats.laws.discipline.{
AlignTests,
AlternativeTests,
Expand All @@ -12,8 +14,8 @@ import cats.laws.discipline.{
TraverseFilterTests,
TraverseTests
}
import cats.data.ZipLazyList
import cats.laws.discipline.arbitrary._
import cats.syntax.all._
import org.scalatest.funsuite.AnyFunSuiteLike

class LazyListSuite extends CatsSuite {
Expand Down
Loading

0 comments on commit 8dd80e5

Please sign in to comment.