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

Remove catalysts dependency #2791

Merged
merged 6 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package alleycats
package tests

import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.Matchers
import org.scalatest.prop.Configuration

trait TestSettings extends Configuration with Matchers {

lazy val checkConfiguration: PropertyCheckConfiguration =
PropertyCheckConfiguration(
minSuccessful = PosInt(5),
maxDiscardedFactor = PosZDouble(50.0),
minSize = PosZInt(0),
sizeRange = PosZInt(5),
workers = PosInt(1)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package alleycats
package tests

import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.Matchers
import org.scalatest.prop.Configuration

trait TestSettings extends Configuration with Matchers {

lazy val checkConfiguration: PropertyCheckConfiguration =
PropertyCheckConfiguration(
minSuccessful = PosInt(50),
maxDiscardedFactor = PosZDouble(5.0),
minSize = PosZInt(0),
sizeRange = PosZInt(10),
workers = PosInt(1)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,18 @@ package alleycats
package tests

import alleycats.std.MapInstances
import catalysts.Platform
import cats._
import cats.instances.AllInstances
import cats.syntax.{AllSyntax, EqOps}
import cats.tests.StrictCatsEquality
import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.{FunSuite, Matchers}
import org.scalatest.prop.{Configuration, GeneratorDrivenPropertyChecks}
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.typelevel.discipline.scalatest.Discipline
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Arbitrary.arbitrary

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

trait TestSettings extends Configuration with Matchers {

lazy val checkConfiguration: PropertyCheckConfiguration =
PropertyCheckConfiguration(
minSuccessful = if (Platform.isJvm) PosInt(50) else PosInt(5),
maxDiscardedFactor = if (Platform.isJvm) PosZDouble(5.0) else PosZDouble(50.0),
minSize = PosZInt(0),
sizeRange = if (Platform.isJvm) PosZInt(10) else PosZInt(5),
workers = PosInt(1)
)

lazy val slowCheckConfiguration: PropertyCheckConfiguration =
if (Platform.isJvm) checkConfiguration
else PropertyCheckConfiguration(sizeRange = 1, minSuccessful = 1)
}

/**
* An opinionated stack of traits to improve consistency and reduce
* boilerplate in Alleycats tests. Derived from Cats.
Expand Down
6 changes: 0 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ lazy val includeGeneratedSrc: Setting[_] = {
}
}

val catalystsVersion = "0.8"

def scalatestVersion(scalaVersion: String): String =
if (priorTo2_13(scalaVersion)) "3.0.5" else "3.0.6-SNAP5"

Expand All @@ -166,8 +164,6 @@ lazy val disciplineDependencies = Seq(
)

lazy val testingDependencies = Seq(
libraryDependencies += "org.typelevel" %%% "catalysts-platform" % catalystsVersion,
libraryDependencies += "org.typelevel" %%% "catalysts-macros" % catalystsVersion % "test",
libraryDependencies += "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value) % "test"
)

Expand Down Expand Up @@ -503,7 +499,6 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform)
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % "test")

lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("kernel-laws"))
.settings(moduleName := "cats-kernel-laws", name := "Cats kernel laws")
.settings(commonSettings)
Expand Down Expand Up @@ -594,7 +589,6 @@ lazy val alleycatsLaws = crossProject(JSPlatform, JVMPlatform)
.jsSettings(coverageEnabled := false)

lazy val alleycatsTests = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("alleycats-tests"))
.dependsOn(alleycatsLaws, testkit % "test")
.settings(moduleName := "alleycats-tests")
Expand Down
9 changes: 9 additions & 0 deletions kernel-laws/js/src/main/scala/cats/platform/Platform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cats.platform

private[cats] object Platform {
// using `final val` makes compiler constant-fold any use of these values, dropping dead code automatically
// $COVERAGE-OFF$
final val isJvm = false
final val isJs = true
// $COVERAGE-ON$
}
9 changes: 9 additions & 0 deletions kernel-laws/jvm/src/main/scala/cats/platform/Platform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cats.platform

private[cats] object Platform {
// using `final val` makes compiler constant-fold any use of these values, dropping dead code automatically
// $COVERAGE-OFF$
final val isJvm = true
final val isJs = false
// $COVERAGE-ON$
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package cats.kernel.laws

import cats.platform.Platform
import org.scalacheck.Prop
import org.scalacheck.Prop.{Exception, Proof, Result}

import catalysts.Platform

import scala.util.control.NonFatal

/**
Expand All @@ -19,14 +18,10 @@ object SerializableLaws {
// This part is a bit tricky. Basically, we only want to test
// serializability on the JVM.
//
// The Platform.isJs macro will give us a literal true or false at
// compile time, so we rely on scalac to prune away the "other"
// branch. Thus, when scala.js look at this method it won't "see"
// the branch which was removed, and will avoid an error trying to
// support java.io.*.
//
// This ends up being a lot nicer than having to split the entire
// laws project.
// `Platform.isJs` is a constant expression, so we can rely on
// scalac to prune away the "other" branch. Thus, when Scala.js
// looks at this method it won't "see" the branch which was removed,
// and will avoid an error trying to support java.io.*.

def serializable[A](a: A): Prop =
if (Platform.isJs) Prop(_ => Result(status = Proof))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package cats.kernel
package laws

import catalysts.Platform
import catalysts.macros.TypeTagM
import cats.kernel.instances.all._
import cats.kernel.laws.discipline._
import cats.platform.Platform

import org.typelevel.discipline.Laws
import org.typelevel.discipline.scalatest.Discipline
import org.scalacheck.{Arbitrary, Cogen, Gen}
import Arbitrary.arbitrary
Expand Down Expand Up @@ -434,14 +432,4 @@ class Tests extends FunSuite with Discipline {
implicit def hasCogen[A: Cogen]: Cogen[HasHash[A]] =
Cogen[A].contramap(_.a)
}

case class LawChecker[L <: Laws](name: String, laws: L) {
def check(f: L => L#RuleSet): Unit = checkAll(name, f(laws))
}

private[laws] def laws[L[_] <: Laws, A](implicit lws: L[A], tag: TypeTagM[A]): LawChecker[L[A]] =
laws[L, A]("")

private[laws] def laws[L[_] <: Laws, A](extraTag: String)(implicit laws: L[A], tag: TypeTagM[A]): LawChecker[L[A]] =
LawChecker("[" + tag.name.toString + (if (extraTag != "") "@@" + extraTag else "") + "]", laws)
}
2 changes: 1 addition & 1 deletion laws/src/main/scala/cats/laws/DeferLaws.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package laws

import catalysts.Platform
import cats.platform.Platform

/**
* Laws that must be obeyed by any `Defer`.
Expand Down
3 changes: 1 addition & 2 deletions laws/src/main/scala/cats/laws/discipline/Eq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package cats
package laws
package discipline

import catalysts.Platform

import cats.data.RepresentableStore
import cats.Eq
import cats.data.AndThen
Expand All @@ -12,6 +10,7 @@ import cats.instances.int._
import cats.instances.string._
import cats.instances.tuple._
import cats.kernel._
import cats.platform.Platform
import cats.syntax.eq._
import org.scalacheck.Arbitrary

Expand Down
2 changes: 1 addition & 1 deletion laws/src/main/scala/cats/laws/discipline/MonadTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cats
package laws
package discipline

import catalysts.Platform
import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.platform.Platform
import org.scalacheck.{Arbitrary, Cogen, Prop}
import Prop._

Expand Down
2 changes: 1 addition & 1 deletion testkit/src/main/scala/cats/tests/CatsSuite.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats
package tests

import catalysts.Platform
import cats.instances._
import cats.platform.Platform
import cats.syntax._
import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.{FunSuite, FunSuiteLike, Matchers}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/AndThenSuite.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cats
package tests

import catalysts.Platform
import cats.data._
import cats.kernel.laws.discipline.SerializableTests
import cats.laws.discipline._
import cats.arrow._
import cats.laws.discipline.eq._
import cats.laws.discipline.arbitrary._
import cats.platform.Platform

class AndThenSuite extends CatsSuite {
checkAll("AndThen[MiniInt, Int]", SemigroupalTests[AndThen[MiniInt, ?]].semigroupal[Int, Int, Int])
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/IndexedStateTSuite.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cats
package tests

import catalysts.Platform
import cats.arrow.{Profunctor, Strong}
import cats.data.{EitherT, IndexedStateT, State, StateT}
import cats.arrow.Profunctor
import cats.kernel.instances.tuple._
import cats.laws.discipline._
import cats.laws.discipline.eq._
import cats.laws.discipline.arbitrary._
import cats.platform.Platform

class IndexedStateTSuite extends CatsSuite {

Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/KleisliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import cats.laws.discipline.arbitrary._
import cats.laws.discipline.eq._
import cats.kernel.laws.discipline.{MonoidTests, SemigroupTests}
import cats.laws.discipline.{DeferTests, MonoidKTests, SemigroupKTests}
import cats.platform.Platform
import Helpers.CSemi
import catalysts.Platform

class KleisliSuite extends CatsSuite {
implicit def kleisliEq[F[_], A, B](implicit ev: Eq[A => F[B]]): Eq[Kleisli[F, A, B]] =
Expand Down
3 changes: 1 addition & 2 deletions tests/src/test/scala/cats/tests/NonEmptyVectorSuite.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cats
package tests

import catalysts.Platform

import cats.data.NonEmptyVector.ZipNonEmptyVector

import cats.kernel.laws.discipline.{EqTests, SemigroupTests}
Expand All @@ -18,6 +16,7 @@ import cats.laws.discipline.{
SerializableTests
}
import cats.laws.discipline.arbitrary._
import cats.platform.Platform

import scala.util.Properties

Expand Down