Skip to content

Commit

Permalink
fix/suppress in 'kernel-laws'
Browse files Browse the repository at this point in the history
  • Loading branch information
satorg committed Jun 9, 2024
1 parent d7c071a commit 2b3ef6d
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait MonoidLaws[A] extends SemigroupLaws[A] {
def repeat0(x: A): IsEq[A] =
S.combineN(x, 0) <-> S.empty

def collect0(x: A): IsEq[A] =
def collect0: IsEq[A] =
S.combineAll(Nil) <-> S.empty

def combineAll(xs: Vector[A]): IsEq[A] =
Expand All @@ -44,6 +44,8 @@ trait MonoidLaws[A] extends SemigroupLaws[A] {
def isId(x: A, eqv: Eq[A]): IsEq[Boolean] =
eqv.eqv(x, S.empty) <-> S.isEmpty(x)(eqv)

@deprecated("use `collect0` without parameters", "2.12.1")
def collect0(x: A): IsEq[A] = collect0
}

object MonoidLaws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
package cats.kernel
package laws

import cats.kernel.Order

trait OrderLaws[A] extends PartialOrderLaws[A] {

implicit override def E: Order[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ import org.scalacheck.Prop.forAll
trait LowerBoundedTests[A] extends PartialOrderTests[A] {
def laws: LowerBoundedLaws[A]

def lowerBounded(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def lowerBounded(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"lowerBounded",
Some(partialOrder),
"bound is less than or equals" -> forAll(laws.boundLteqv _)
)

@deprecated("use `lowerBounded` without `Eq` paramerters", "2.12.1")
def lowerBounded(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
lowerBounded(arbA, arbF)
}

object LowerBoundedTests {
Expand All @@ -47,12 +51,16 @@ object LowerBoundedTests {
trait UpperBoundedTests[A] extends PartialOrderTests[A] {
def laws: UpperBoundedLaws[A]

def upperBounded(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def upperBounded(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"upperBounded",
Some(partialOrder),
"bound is greater than or equals" -> forAll(laws.boundGteqv _)
)

@deprecated("use `upperBounded` without `Eq` paramerters", "2.12.1")
def upperBounded(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
upperBounded(arbA, arbF)
}

object UpperBoundedTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,41 @@ trait PartialNextTests[A] extends PartialOrderTests[A] {

def laws: PartialNextLaws[A]

def partialNext(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def partialNext(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"partialNext",
Some(partialOrder),
"next(a) > a" -> forAll(laws.nextOrderWeak _),
"forall a, b. if a < b. next(a) <= b" -> forAll(laws.nextOrderStrong _)
)

@deprecated("use `partialNext` without `Eq` parameters", "2.12.1")
def partialNext(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
partialNext(arbA, arbF)
}

trait PartialPreviousTests[A] extends PartialOrderTests[A] {

def laws: PartialPreviousLaws[A]

def partialPrevious(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def partialPrevious(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"partialPrevious",
Some(partialOrder),
"next(a) > a" -> forAll(laws.previousOrderWeak _),
"forall a, b. if a < b. next(a) <= b" -> forAll(laws.previousOrderStrong _)
)

@deprecated("use `partialPrevious` without `Eq` parameters", "2.12.1")
def partialPrevious(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
partialPrevious(arbA, arbF)
}

trait BoundedEnumerableTests[A] extends OrderTests[A] with PartialNextTests[A] with PartialPreviousTests[A] {

def laws: BoundedEnumerableLaws[A]

def boundedEnumerable(implicit
arbA: Arbitrary[A],
arbF: Arbitrary[A => A],
eqOA: Eq[Option[A]],
eqA: Eq[A]
): RuleSet =
def boundedEnumerable(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]]): RuleSet =
new RuleSet {
val name: String = "boundedEnumerable"
val bases: Seq[(String, RuleSet)] = Nil
Expand All @@ -78,6 +79,14 @@ trait BoundedEnumerableTests[A] extends OrderTests[A] with PartialNextTests[A] w
)
}

@deprecated("use `boundedEnumerable` without `Eq[A]` parameter", "2.12.1")
def boundedEnumerable(
arbA: Arbitrary[A],
arbF: Arbitrary[A => A],
eqOA: Eq[Option[A]],
eqA: Eq[A]
): RuleSet =
boundedEnumerable(arbA, arbF, eqOA)
}

object BoundedEnumerableTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ trait HashTests[A] extends EqTests[A] {

def laws: HashLaws[A]

def hash(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqA: Eq[A], hashA: Hashing[A]): RuleSet =
def hash(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"hash",
Some(eqv),
"hash compatibility" -> forAll(laws.hashCompatibility _)
)

@deprecated("use `hash` without `Hashing` parameter", "2.12.1")
def hash(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqA: Eq[A], hashA: Hashing[A]): RuleSet =
hash(arbA, arbF)
}

object HashTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package discipline

import cats.kernel.instances.boolean._
import org.scalacheck.Arbitrary
import org.scalacheck.Prop
import org.scalacheck.Prop.forAll

trait MonoidTests[A] extends SemigroupTests[A] {
Expand All @@ -39,7 +40,7 @@ trait MonoidTests[A] extends SemigroupTests[A] {
"left identity" -> forAll(laws.leftIdentity _),
"right identity" -> forAll(laws.rightIdentity _),
"combine all" -> forAll(laws.combineAll _),
"collect0" -> forAll(laws.collect0 _),
"collect0" -> (laws.collect0: Prop),
"is id" -> forAll((a: A) => laws.isId(a, eqA)),
"repeat0" -> forAll(laws.repeat0 _)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait OrderTests[A] extends PartialOrderTests[A] {

def laws: OrderLaws[A]

def order(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def order(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"order",
Some(partialOrder),
Expand All @@ -42,6 +42,9 @@ trait OrderTests[A] extends PartialOrderTests[A] {
"min" -> forAll(laws.min _)
)

@deprecated("use `order` without `Eq` parameters", "2.12.1")
def order(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
order(arbA, arbF)
}

object OrderTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait PartialOrderTests[A] extends EqTests[A] {

def laws: PartialOrderLaws[A]

def partialOrder(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
def partialOrder(implicit arbA: Arbitrary[A], arbF: Arbitrary[A => A]): RuleSet =
new DefaultRuleSet(
"partialOrder",
Some(eqv),
Expand All @@ -48,6 +48,9 @@ trait PartialOrderTests[A] extends EqTests[A] {
"pmin" -> forAll(laws.pmin _)
)

@deprecated("use `partialOrder` without `Eq` parameters", "2.12.1")
def partialOrder(arbA: Arbitrary[A], arbF: Arbitrary[A => A], eqOA: Eq[Option[A]], eqA: Eq[A]): RuleSet =
partialOrder(arbA, arbF)
}

object PartialOrderTests {
Expand Down

0 comments on commit 2b3ef6d

Please sign in to comment.