Skip to content

Commit

Permalink
Start migrating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Jun 19, 2021
1 parent 66a6231 commit 2943b54
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.typelevel.discipline.Laws

import org.scalacheck.{Arbitrary, Prop}

@deprecated("No replacement", since = "2.7.0")
object BaseLaws {
def apply[A: Eq: Arbitrary]: BaseLaws[A] = new BaseLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
}
}

@deprecated("No replacement", since = "2.7.0")
trait BaseLaws[A] extends Laws {

implicit def Equ: Eq[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ package algebra.laws
* (Since algebra-instances has no dependencies, its types can't
* define Arbitrary instances in companions.)
*/
@deprecated("No replacement", since = "2.7.0")
object CheckSupport {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Prop._
import org.typelevel.discipline.Laws

@deprecated("Laws moved to LogicLaws", since = "2.7.0")
object DeMorganLaws {
def apply[A: Eq: Arbitrary: LatticeLaws] = new DeMorganLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
def LL = implicitly[LatticeLaws[A]]
}
}
/* TODO:
* This is separated for LogicLaws for binary compatibility reasons.
* Merge with LogicLaws when possible.
*/

@deprecated("Laws moved to LogicLaws", since = "2.7.0")
trait DeMorganLaws[A] extends Laws {

implicit def Equ: Eq[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import org.typelevel.discipline.Laws
import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Prop._

@deprecated("Provided by cats.kernel.laws", since = "2.7.0")
object GroupLaws {
def apply[A: Eq: Arbitrary]: GroupLaws[A] = new GroupLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
}
}

@deprecated("Provided by cats.kernel.laws", since = "2.7.0")
trait GroupLaws[A] extends Laws {

implicit def Equ: Eq[A]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import algebra.lattice._

import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Prop._
import scala.annotation.nowarn

object LatticeLaws {
def apply[A: Eq: Arbitrary] = new LatticeLaws[A] {
Expand All @@ -13,6 +14,7 @@ object LatticeLaws {
}
}

@nowarn("msg=deprecated")
trait LatticeLaws[A] extends GroupLaws[A] {

implicit def Equ: Eq[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import algebra.lattice.{Bool, GenBool, Heyting}

import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Prop._
import scala.annotation.nowarn

object LogicLaws {
def apply[A: Eq: Arbitrary] = new LogicLaws[A] {
Expand All @@ -13,7 +14,10 @@ object LogicLaws {
}
}

trait LogicLaws[A] extends LatticeLaws[A] {
@nowarn("msg=deprecated")
trait LogicLaws[A] extends LatticeLaws[A] with DeMorganLaws[A] {

final def LL: LatticeLaws[A] = this

def heyting(implicit A: Heyting[A]) = new LogicProperties(
name = "heyting",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.scalacheck.Prop._

import cats.kernel.instances.all._

@deprecated("Provided by cats.kernel.laws", since = "2.7.0")
object OrderLaws {
def apply[A: Eq: Arbitrary: Cogen]: OrderLaws[A] =
new OrderLaws[A] {
Expand All @@ -18,6 +19,7 @@ object OrderLaws {
}
}

@deprecated("Provided by cats.kernel.laws", since = "2.7.0")
trait OrderLaws[A] extends Laws {

implicit def Equ: Eq[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.typelevel.discipline.Predicate
import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Arbitrary._
import org.scalacheck.Prop._
import scala.annotation.nowarn

object RingLaws {
def apply[A: Eq: Arbitrary: AdditiveMonoid]: RingLaws[A] =
Expand All @@ -20,13 +21,15 @@ object RingLaws {
def withPred[A](pred0: Predicate[A])(implicit eqv: Eq[A], arb: Arbitrary[A]): RingLaws[A] = new RingLaws[A] {
def Arb = arb
def pred = pred0
@nowarn("msg=deprecated")
val nonZeroLaws = new GroupLaws[A] {
def Arb = Arbitrary(arbitrary[A](arb).filter(pred))
def Equ = eqv
}
}
}

@nowarn("msg=deprecated")
trait RingLaws[A] extends GroupLaws[A] { self =>

// must be a val (stable identifier)
Expand Down
10 changes: 3 additions & 7 deletions algebra-laws/shared/src/main/scala/algebra/laws/Rules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cats.kernel._
import org.scalacheck.Prop._
import org.scalacheck.{Arbitrary, Prop}
import cats.kernel.instances.boolean._
import cats.kernel.laws.discipline.SerializableTests

object Rules {

Expand Down Expand Up @@ -92,12 +93,7 @@ object Rules {
(m(a(x, y), z) ?== a(m(x, z), m(y, z)))
}

// ugly platform-specific code follows

@deprecated("Provided by cats.kernel.laws", since = "2.7.0")
def serializable[M](m: M): (String, Prop) =
"serializable" -> (if (IsSerializable()) {
Prop(_ => Result(status = Proof))
} else {
Prop(_ => IsSerializable.testSerialization(m))
})
SerializableTests.serializable[M](m).props.head
}
12 changes: 10 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ def mimaSettings(moduleName: String, includeCats1: Boolean = true) =
exclude[MissingClassProblem]("cats.syntax.EqOps$"),
exclude[MissingClassProblem]("cats.syntax.EqOps$mcF$sp"),
exclude[MissingClassProblem]("cats.syntax.EqOps$mcI$sp")
) ++ // https://github.com/typelevel/cats/pull/3918
Seq(
exclude[MissingClassProblem]("algebra.laws.IsSerializable"),
exclude[MissingClassProblem]("algebra.laws.IsSerializable$")
)
}
)
Expand Down Expand Up @@ -705,8 +709,12 @@ lazy val algebraLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(testingDependencies)
.settings(Test / scalacOptions := (Test / scalacOptions).value.filter(_ != "-Xfatal-warnings"))
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.dependsOn(kernel, algebra)
.jvmSettings(
commonJvmSettings ++ mimaSettings("algebra-laws") ++ Seq(
mimaPreviousArtifacts := Set("org.typelevel" %% "algebra-laws" % "2.2.3")
)
)
.dependsOn(kernelLaws, algebra)
.nativeSettings(commonNativeSettings)

lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
Expand Down

0 comments on commit 2943b54

Please sign in to comment.