diff --git a/core/src/main/scala/cats/data/IdT.scala b/core/src/main/scala/cats/data/IdT.scala index a0f3f05a4bd..607b91c1074 100644 --- a/core/src/main/scala/cats/data/IdT.scala +++ b/core/src/main/scala/cats/data/IdT.scala @@ -21,9 +21,18 @@ final case class IdT[F[_], A](value: F[A]) { def foldRight[B](lb: Eval[B])(f: (A, Eval[B]) => Eval[B])(implicit F: Foldable[F]): Eval[B] = F.foldRight(value, lb)(f) + def reduceLeftTo[B](f: A => B)(g: (B, A) => B)(implicit F: Reducible[F]): B = + F.reduceLeftTo(value)(f)(g) + + def reduceRightTo[B](f: A => B)(g: (A, Eval[B]) => Eval[B])(implicit F: Reducible[F]): Eval[B] = + F.reduceRightTo(value)(f)(g) + def traverse[G[_], B](f: A => G[B])(implicit F: Traverse[F], G: Applicative[G]): G[IdT[F, B]] = G.map(F.traverse(value)(f))(IdT(_)) + def nonEmptyTraverse[G[_], B](f: A => G[B])(implicit F: NonEmptyTraverse[F], G: Apply[G]): G[IdT[F, B]] = + G.map(F.nonEmptyTraverse(value)(f))(IdT(_)) + def ap[B](f: IdT[F, A => B])(implicit F: Apply[F]): IdT[F, B] = IdT(F.ap(f.value)(value)) @@ -91,33 +100,51 @@ private[data] sealed trait IdTTraverse[F[_]] extends Traverse[IdT[F, ?]] with Id fa.traverse(f) } -private[data] sealed abstract class IdTInstances4 { +private[data] sealed trait IdTNonEmptyTraverse[F[_]] extends IdTTraverse[F] with NonEmptyTraverse[IdT[F, ?]] with IdTFunctor[F] { + implicit val F0: NonEmptyTraverse[F] + + def nonEmptyTraverse[G[_]: Apply, A, B](fa: IdT[F, A])(f: A => G[B]): G[IdT[F, B]] = + fa.nonEmptyTraverse(f) + + def reduceLeftTo[A, B](fa: IdT[F, A])(f: A => B)(g: (B, A) => B): B = + fa.reduceLeftTo(f)(g) + + def reduceRightTo[A, B](fa: IdT[F, A])(f: A => B)(g: (A, Eval[B]) => Eval[B]): Eval[B] = + fa.reduceRightTo(f)(g) +} + +private[data] sealed abstract class IdTInstances5 { implicit def catsDataFunctorForIdT[F[_]](implicit F: Functor[F]): Functor[IdT[F, ?]] = new IdTFunctor[F] { implicit val F0: Functor[F] = F } } -private[data] sealed abstract class IdTInstances3 extends IdTInstances4 { +private[data] sealed abstract class IdTInstances4 extends IdTInstances5 { implicit def catsDataApplyForIdT[F[_]](implicit F: Apply[F]): Apply[IdT[F, ?]] = new IdTApply[F] { implicit val F0: Apply[F] = F } } -private[data] sealed abstract class IdTInstances2 extends IdTInstances3 { +private[data] sealed abstract class IdTInstances3 extends IdTInstances4 { implicit def catsDataApplicativeForIdT[F[_]](implicit F: Applicative[F]): Applicative[IdT[F, ?]] = new IdTApplicative[F] { implicit val F0: Applicative[F] = F } } -private[data] sealed abstract class IdTInstances1 extends IdTInstances2 { +private[data] sealed abstract class IdTInstances2 extends IdTInstances3 { implicit def catsDataFlatMapForIdT[F[_]](implicit F: FlatMap[F]): FlatMap[IdT[F, ?]] = new IdTFlatMap[F] { implicit val F0: FlatMap[F] = F } } -private[data] sealed abstract class IdTInstances0 extends IdTInstances1 { - +private[data] sealed abstract class IdTInstances1 extends IdTInstances2 { implicit def catsDataMonadForIdT[F[_]](implicit F: Monad[F]): Monad[IdT[F, ?]] = new IdTMonad[F] { implicit val F0: Monad[F] = F } implicit def catsDataFoldableForIdT[F[_]](implicit F: Foldable[F]): Foldable[IdT[F, ?]] = new IdTFoldable[F] { implicit val F0: Foldable[F] = F } +} + +private[data] sealed abstract class IdTInstances0 extends IdTInstances1 { + + implicit def catsDataTraverseForIdT[F[_]](implicit F: Traverse[F]): Traverse[IdT[F, ?]] = + new IdTTraverse[F] { implicit val F0: Traverse[F] = F } implicit def catsDataEqForIdT[F[_], A](implicit F: Eq[F[A]]): Eq[IdT[F, A]] = F.on(_.value) @@ -125,8 +152,8 @@ private[data] sealed abstract class IdTInstances0 extends IdTInstances1 { private[data] sealed abstract class IdTInstances extends IdTInstances0 { - implicit def catsDataTraverseForIdT[F[_]](implicit F: Traverse[F]): Traverse[IdT[F, ?]] = - new IdTTraverse[F] { implicit val F0: Traverse[F] = F } + implicit def catsDataNonEmptyTraverseForIdT[F[_]](implicit F: NonEmptyTraverse[F]): NonEmptyTraverse[IdT[F, ?]] = + new IdTNonEmptyTraverse[F] { implicit val F0: NonEmptyTraverse[F] = F } implicit def catsDataOrderForIdT[F[_], A](implicit F: Order[F[A]]): Order[IdT[F, A]] = F.on(_.value) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index dcba546be67..4de780eccad 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -276,11 +276,10 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { * res0: cats.data.NonEmptyList[(Char, Int)] = NonEmptyList((z,1), (a,4), (e,22)) * }}} */ - def sortBy[B](f: A => B)(implicit B: Order[B]): NonEmptyList[A] = - toList.sortBy(f)(B.toOrdering) match { - case x :: xs => NonEmptyList(x, xs) - case Nil => sys.error("unreachable: sorting a NonEmptyList cannot produce an empty List") - } + def sortBy[B](f: A => B)(implicit B: Order[B]): NonEmptyList[A] = { + // safe: sorting a NonEmptyList cannot produce an empty List + NonEmptyList.fromListUnsafe(toList.sortBy(f)(B.toOrdering)) + } /** * Sorts this `NonEmptyList` according to an `Order` @@ -293,11 +292,10 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { * res0: cats.data.NonEmptyList[Int] = NonEmptyList(3, 4, 9, 12) * }}} */ - def sorted[AA >: A](implicit AA: Order[AA]): NonEmptyList[AA] = - toList.sorted(AA.toOrdering) match { - case x :: xs => NonEmptyList(x, xs) - case Nil => sys.error("unreachable: sorting a NonEmptyList cannot produce an empty List") - } + def sorted[AA >: A](implicit AA: Order[AA]): NonEmptyList[AA] = { + // safe: sorting a NonEmptyList cannot produce an empty List + NonEmptyList.fromListUnsafe(toList.sorted(AA.toOrdering)) + } /** * Groups elements inside of this `NonEmptyList` using a mapping function diff --git a/core/src/main/scala/cats/instances/stream.scala b/core/src/main/scala/cats/instances/stream.scala index 4af61f8144c..3e874acc2a8 100644 --- a/core/src/main/scala/cats/instances/stream.scala +++ b/core/src/main/scala/cats/instances/stream.scala @@ -21,9 +21,6 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { def flatMap[A, B](fa: Stream[A])(f: A => Stream[B]): Stream[B] = fa.flatMap(f) - override def map2[A, B, Z](fa: Stream[A], fb: Stream[B])(f: (A, B) => Z): Stream[Z] = - fa.flatMap(a => fb.map(b => f(a, b))) - def coflatMap[A, B](fa: Stream[A])(f: Stream[A] => B): Stream[B] = fa.tails.toStream.init.map(f) diff --git a/free/src/test/scala/cats/free/FreeTests.scala b/free/src/test/scala/cats/free/FreeTests.scala index 54089f09650..4097b36e105 100644 --- a/free/src/test/scala/cats/free/FreeTests.scala +++ b/free/src/test/scala/cats/free/FreeTests.scala @@ -90,6 +90,14 @@ class FreeTests extends CatsSuite { assert(res == List(112358)) } + test(".run") { + val r = Free.pure[Id, Int](12358) + def recurse(r: Free[Id, Int], n: Int): Free[Id, Int] = + if (n > 0) recurse(r.flatMap(x => Free.pure(x + 1)), n - 1) else r + val res = recurse(r, 100000).run + assert(res == 112358) + } + sealed trait Test1Algebra[A] case class Test1[A](value : Int, f: Int => A) extends Test1Algebra[A] diff --git a/jvm/src/test/scala/cats/tests/FutureTests.scala b/jvm/src/test/scala/cats/tests/FutureTests.scala index 4b72eb8bc14..bf011071a8d 100644 --- a/jvm/src/test/scala/cats/tests/FutureTests.scala +++ b/jvm/src/test/scala/cats/tests/FutureTests.scala @@ -10,9 +10,9 @@ import cats.tests.{CatsSuite, ListWrapper} import scala.concurrent.{Await, Future} import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global - -import org.scalacheck.Arbitrary +import org.scalacheck.{Arbitrary, Cogen} import org.scalacheck.Arbitrary.arbitrary +import org.scalacheck.rng.Seed class FutureTests extends CatsSuite { val timeout = 3.seconds @@ -28,6 +28,9 @@ class FutureTests extends CatsSuite { } } + implicit def cogen[A: Cogen]: Cogen[Future[A]] = + Cogen[Future[A]] { (seed: Seed, t: Future[A]) => Cogen[A].perturb(seed, Await.result(t, timeout)) } + implicit val throwableEq: Eq[Throwable] = Eq[String].on(_.toString) @@ -37,6 +40,7 @@ class FutureTests extends CatsSuite { checkAll("Future with Throwable", MonadErrorTests[Future, Throwable].monadError[Int, Int, Int]) checkAll("Future", MonadTests[Future].monad[Int, Int, Int]) + checkAll("Future", CoflatMapTests[Future].coflatMap[Int, Int, Int]) { implicit val F = ListWrapper.semigroup[Int] diff --git a/macros/src/main/scala/cats/macros/Ops.scala b/macros/src/main/scala/cats/macros/Ops.scala index ec904a07382..7dfadc892b9 100644 --- a/macros/src/main/scala/cats/macros/Ops.scala +++ b/macros/src/main/scala/cats/macros/Ops.scala @@ -5,8 +5,6 @@ import scala.reflect.NameTransformer object Ops extends machinist.Ops { - def uesc(c: Char): String = "$u%04X".format(c.toInt) - val operatorNames: Map[String, String] = List( ("===", "eqv"), diff --git a/tests/src/test/scala/cats/tests/ApplicativeTests.scala b/tests/src/test/scala/cats/tests/ApplicativeTests.scala index 159a669ec66..1cb029df3f6 100644 --- a/tests/src/test/scala/cats/tests/ApplicativeTests.scala +++ b/tests/src/test/scala/cats/tests/ApplicativeTests.scala @@ -6,12 +6,15 @@ import cats.Applicative class ApplicativeTests extends CatsSuite { - test("replicateA creates a List of 'n' copies of given Applicative 'fa'") { + test("Applicative#traverse is equivalent to Traverse#traverse") { + val f: (Int) => Option[Int] = x => Some(x + 1) + Applicative[Option].traverse(List(1, 2))(f) should ===(Traverse[List].traverse(List(1, 2))(f)) + } + test("replicateA creates a List of 'n' copies of given Applicative 'fa'") { val A = Applicative[Option] val fa = A.pure(1) fa.replicateA(5) should === (Some(List(1,1,1,1,1))) - } test("whenA return given argument when cond is true") { diff --git a/tests/src/test/scala/cats/tests/ComposeTest.scala b/tests/src/test/scala/cats/tests/ComposeTest.scala index 55c3df6bc48..d848901f2c5 100644 --- a/tests/src/test/scala/cats/tests/ComposeTest.scala +++ b/tests/src/test/scala/cats/tests/ComposeTest.scala @@ -16,4 +16,9 @@ class ComposeTest extends CatsSuite { val functionAlgebra = functionCompose.algebra[Int] checkAll("Compose[Function1].algebra[Int]", GroupLaws[Endo[Int]].semigroup(functionAlgebra)) + + test("syntax") { + (((_: Int) + 1) <<< ((_: Int) / 2))(2) should be(2) + (((_: Int) + 1) >>> ((_: Int) / 2))(5) should be(3) + } } diff --git a/tests/src/test/scala/cats/tests/EitherTests.scala b/tests/src/test/scala/cats/tests/EitherTests.scala index 5a31ee9e10a..c7f9f863037 100644 --- a/tests/src/test/scala/cats/tests/EitherTests.scala +++ b/tests/src/test/scala/cats/tests/EitherTests.scala @@ -10,6 +10,7 @@ class EitherTests extends CatsSuite { implicit val iso = CartesianTests.Isomorphisms.invariant[Either[Int, ?]] checkAll("Either[String, Int]", GroupLaws[Either[String, Int]].monoid) + checkAll("Semigroup[Either[String, Int]]", SerializableTests.serializable(Semigroup[Either[String, Int]])) checkAll("Either[Int, Int]", CartesianTests[Either[Int, ?]].cartesian[Int, Int, Int]) checkAll("Cartesian[Either[Int, ?]]", SerializableTests.serializable(Cartesian[Either[Int, ?]])) @@ -28,6 +29,9 @@ class EitherTests extends CatsSuite { checkAll("Either[ListWrapper[String], ?]", SemigroupKTests[Either[ListWrapper[String], ?]].semigroupK[Int]) checkAll("SemigroupK[Either[ListWrapper[String], ?]]", SerializableTests.serializable(SemigroupK[Either[ListWrapper[String], ?]])) + checkAll("Either[ListWrapper[String], Int]", GroupLaws[Either[ListWrapper[String], Int]].semigroup) + checkAll("Semigroup[Either[ListWrapper[String], Int]]", SerializableTests.serializable(Semigroup[Either[ListWrapper[String], Int]])) + val partialOrder = catsStdPartialOrderForEither[Int, String] val order = implicitly[Order[Either[Int, String]]] val monad = implicitly[Monad[Either[Int, ?]]] diff --git a/tests/src/test/scala/cats/tests/EvalTests.scala b/tests/src/test/scala/cats/tests/EvalTests.scala index 90bbf70f8d8..d67d6500a67 100644 --- a/tests/src/test/scala/cats/tests/EvalTests.scala +++ b/tests/src/test/scala/cats/tests/EvalTests.scala @@ -72,14 +72,17 @@ class EvalTests extends CatsSuite { } test(".value should evaluate only once on the result of .memoize"){ - forAll { i: Eval[Int] => - val spooky = new Spooky - val i2 = i.map(_ => spooky.increment).memoize - i2.value - spooky.counter should === (1) - i2.value - spooky.counter should === (1) - } + val spooky = new Spooky + val i2 = Eval.always(spooky.increment()).memoize + val i3 = Eval.now(()).flatMap(_ => Eval.later(spooky.increment())).memoize + i2.value + spooky.counter should === (1) + i2.value + spooky.counter should === (1) + i3.value + spooky.counter should === (2) + i3.value + spooky.counter should === (2) } { diff --git a/tests/src/test/scala/cats/tests/GroupTests.scala b/tests/src/test/scala/cats/tests/GroupTests.scala new file mode 100644 index 00000000000..89651d0403b --- /dev/null +++ b/tests/src/test/scala/cats/tests/GroupTests.scala @@ -0,0 +1,26 @@ +package cats +package tests + +import cats.kernel.laws.GroupLaws + +class GroupTests extends CatsSuite { + test("combine minValue") { + Group[Int].combineN(1, Int.MinValue) should ===(Int.MinValue) + } + + test("combine negative") { + Group[Int].combineN(1, -1) should ===(-1) + Group[Int].combineN(1, -10) should ===(-10) + } + + test("companion object syntax") { + Group[Int].inverse(1) should ===(-1) + Group[Int].remove(1, 2) should ===(-1) + } + + checkAll("Int", GroupLaws[Int].group) + checkAll("Double", GroupLaws[Double].group) +// float is *not* associative, and scalacheck knows +// checkAll("Float", GroupLaws[Float].group) + checkAll("Long", GroupLaws[Long].group) +} diff --git a/tests/src/test/scala/cats/tests/IdTTests.scala b/tests/src/test/scala/cats/tests/IdTTests.scala index 7b665a3bd9b..2c05aa80fbe 100644 --- a/tests/src/test/scala/cats/tests/IdTTests.scala +++ b/tests/src/test/scala/cats/tests/IdTTests.scala @@ -1,7 +1,8 @@ package cats package tests -import cats.data.IdT +import cats.{Foldable, Functor, Monad, NonEmptyTraverse, Traverse} +import cats.data.{IdT, NonEmptyList} import cats.kernel.laws.OrderLaws import cats.laws.discipline._ import cats.laws.discipline.arbitrary._ @@ -76,6 +77,13 @@ class IdTTests extends CatsSuite { checkAll("Traverse[IdT[ListWrapper, ?]]", SerializableTests.serializable(Traverse[IdT[ListWrapper, ?]])) } + { + implicit val F = NonEmptyList.catsDataInstancesForNonEmptyList + + checkAll("IdT[NonEmptyList, Int]", NonEmptyTraverseTests[IdT[NonEmptyList, ?]].nonEmptyTraverse[Option, Int, Int, Int, Int, Option, Option]) + checkAll("NonEmptyTraverse[IdT[NonEmptyList, ?]]", SerializableTests.serializable(NonEmptyTraverse[IdT[NonEmptyList, ?]])) + } + test("flatMap and flatMapF consistent") { forAll { (idT: IdT[Option, Int], f: Int => IdT[Option, Int]) => diff --git a/tests/src/test/scala/cats/tests/IsTests.scala b/tests/src/test/scala/cats/tests/IsTests.scala new file mode 100644 index 00000000000..fba2ebe63b1 --- /dev/null +++ b/tests/src/test/scala/cats/tests/IsTests.scala @@ -0,0 +1,19 @@ +package cats +package tests + +class IsTests extends CatsSuite { + import evidence._ + + test("syntax") { + trait Bar + + val lifted: Bar Is Bar = Is.refl[Bar] + val andThen: Leibniz[Bar, Bar] = lifted.andThen(lifted) + val compose: Leibniz[Bar, Bar] = lifted.compose(lifted) + val flip: Leibniz[Bar, Bar] = lifted.flip + val lift: Leibniz[List[Bar], List[Bar]] = lifted.lift[List] + val coerce: Bar = lifted.coerce(new Bar {}) + val predefEq: =:=[Bar, Bar] = lifted.predefEq + } + +} diff --git a/tests/src/test/scala/cats/tests/KleisliTests.scala b/tests/src/test/scala/cats/tests/KleisliTests.scala index 50ea3673c3a..4b11b361ce0 100644 --- a/tests/src/test/scala/cats/tests/KleisliTests.scala +++ b/tests/src/test/scala/cats/tests/KleisliTests.scala @@ -138,6 +138,36 @@ class KleisliTests extends CatsSuite { } } + test("mapF") { + forAll { (f: Kleisli[List, Int, Int], t: List[Int] => List[Int], i: Int) => + t(f.run(i)) should === (f.mapF(t).run(i)) + } + } + + test("flatMapF") { + forAll { (f: Kleisli[List, Int, Int], t: Int => List[Int], i: Int) => + f.run(i).flatMap(t) should === (f.flatMapF(t).run(i)) + } + } + + test("lower") { + forAll { (f: Kleisli[List, Int, Int], i: Int) => + f.run(i) should === (f.lower.run(i).flatten) + } + } + + test("apply") { + forAll { (f: Kleisli[List, Int, Int], i: Int) => + f.run(i) should === (f(i)) + } + } + + test("traverse") { + forAll { (f: Kleisli[List, Int, Int], i: Int) => + f.traverse(Some(i): Option[Int]) should === ((Some(i): Option[Int]).traverse(f(_))) + } + } + test("lift") { val f = Kleisli { (x: Int) => (Some(x + 1): Option[Int]) } val l = f.lift[List] diff --git a/tests/src/test/scala/cats/tests/MonoidTests.scala b/tests/src/test/scala/cats/tests/MonoidTests.scala index 22ca66652d2..52ccaebaff3 100644 --- a/tests/src/test/scala/cats/tests/MonoidTests.scala +++ b/tests/src/test/scala/cats/tests/MonoidTests.scala @@ -1,22 +1,29 @@ package cats package tests -import org.scalatest._ - import cats.functor._ -class MonoidTests extends FunSuite { +class MonoidTests extends CatsSuite { { - import cats.implicits._ Invariant[Monoid] Cartesian[Monoid] InvariantMonoidal[Monoid] } - { + test("companion object syntax") { + Monoid.empty[Int] should ===(0) + Monoid.isEmpty(1) should ===(false) + Monoid.isEmpty(0) should ===(true) + } +} + +object MonoidTests { + def summonInstance(): Unit = { import cats.instances.monoid._ Invariant[Monoid] Cartesian[Monoid] InvariantMonoidal[Monoid] + () } + } diff --git a/tests/src/test/scala/cats/tests/NonEmptyListTests.scala b/tests/src/test/scala/cats/tests/NonEmptyListTests.scala index e2b360777e4..8b00719d8cc 100644 --- a/tests/src/test/scala/cats/tests/NonEmptyListTests.scala +++ b/tests/src/test/scala/cats/tests/NonEmptyListTests.scala @@ -2,9 +2,8 @@ package cats package tests import cats.kernel.laws.{GroupLaws, OrderLaws} - -import cats.data.NonEmptyList -import cats.laws.discipline.{ComonadTests, SemigroupKTests, MonadTests, SerializableTests, NonEmptyTraverseTests, ReducibleTests} +import cats.data.{NonEmptyList, NonEmptyVector} +import cats.laws.discipline.{ComonadTests, MonadTests, NonEmptyTraverseTests, ReducibleTests, SemigroupKTests, SerializableTests} import cats.laws.discipline.arbitrary._ class NonEmptyListTests extends CatsSuite { @@ -274,6 +273,12 @@ class NonEmptyListTests extends CatsSuite { NonEmptyList.fromList(xs) should === (NonEmptyList.fromFoldable(xs)) } } + + test("NonEmptyList#fromReducible is consistent with Reducible#toNonEmptyList") { + forAll { (xs: NonEmptyVector[Int]) => + NonEmptyList.fromReducible(xs) should === (Reducible[NonEmptyVector].toNonEmptyList(xs)) + } + } } class ReducibleNonEmptyListCheck extends ReducibleCheck[NonEmptyList]("NonEmptyList") { diff --git a/tests/src/test/scala/cats/tests/OrderTests.scala b/tests/src/test/scala/cats/tests/OrderTests.scala index e319a4b9223..c726e0c661f 100644 --- a/tests/src/test/scala/cats/tests/OrderTests.scala +++ b/tests/src/test/scala/cats/tests/OrderTests.scala @@ -2,19 +2,25 @@ package cats package tests import cats.functor._ +import cats.kernel.laws.OrderLaws -import org.scalatest._ - -class OrderTests extends FunSuite { +class OrderTests extends CatsSuite { { - import cats.implicits._ Invariant[Order] Contravariant[Order] } - { + checkAll("Int", OrderLaws[Int].order) + checkAll("Double", OrderLaws[Double].order) + checkAll("Float", OrderLaws[Float].order) + checkAll("Long", OrderLaws[Long].order) +} + +object OrderTests { + def summonInstance(): Unit = { import cats.instances.order._ Invariant[Order] Contravariant[Order] + () } -} +} \ No newline at end of file diff --git a/tests/src/test/scala/cats/tests/PartialOrderTests.scala b/tests/src/test/scala/cats/tests/PartialOrderTests.scala index 4ad8cd5513a..5b048ae156d 100644 --- a/tests/src/test/scala/cats/tests/PartialOrderTests.scala +++ b/tests/src/test/scala/cats/tests/PartialOrderTests.scala @@ -1,20 +1,31 @@ package cats package tests -import org.scalatest._ - import cats.functor._ -class PartialOrderTests extends FunSuite { +class PartialOrderTests extends CatsSuite { { - import cats.implicits._ Invariant[PartialOrder] Contravariant[PartialOrder] } - { + test("companion object syntax") { + PartialOrder.partialCompare(1, 2) should ===(catsKernelStdOrderForInt.partialCompare(1, 2)) + PartialOrder.tryCompare(1, 2) should ===(catsKernelStdOrderForInt.tryCompare(1, 2)) + PartialOrder.pmin(1, 2) should ===(catsKernelStdOrderForInt.pmin(1, 2)) + PartialOrder.pmax(1, 2) should ===(catsKernelStdOrderForInt.pmax(1, 2)) + PartialOrder.lteqv(1, 2) should ===(catsKernelStdOrderForInt.lteqv(1, 2)) + PartialOrder.lt(1, 2) should ===(catsKernelStdOrderForInt.lt(1, 2)) + PartialOrder.gteqv(1, 2) should ===(catsKernelStdOrderForInt.gteqv(1, 2)) + PartialOrder.gt(1, 2) should ===(catsKernelStdOrderForInt.gt(1, 2)) + } +} + +object PartialOrderTests { + def summonInstance(): Unit = { import cats.instances.partialOrder._ Invariant[PartialOrder] Contravariant[PartialOrder] + () } } diff --git a/tests/src/test/scala/cats/tests/SplitTest.scala b/tests/src/test/scala/cats/tests/SplitTest.scala new file mode 100644 index 00000000000..3cc5af0d838 --- /dev/null +++ b/tests/src/test/scala/cats/tests/SplitTest.scala @@ -0,0 +1,9 @@ +package cats +package tests + +class SplitTest extends CatsSuite { + test("syntax") { + val f = (((_: Int) + 1) split ((_: Int) / 2)) + f((1, 2)) should be((2, 1)) + } +} diff --git a/tests/src/test/scala/cats/tests/WriterTTests.scala b/tests/src/test/scala/cats/tests/WriterTTests.scala index 5dbd4042a08..50274a9503e 100644 --- a/tests/src/test/scala/cats/tests/WriterTTests.scala +++ b/tests/src/test/scala/cats/tests/WriterTTests.scala @@ -335,11 +335,10 @@ class WriterTTests extends CatsSuite { implicit val FLV: Monoid[ListWrapper[(Int, Int)]] = ListWrapper.monoid[(Int, Int)] Monoid[WriterT[ListWrapper, Int, Int]] - Semigroup[WriterT[ListWrapper, Int, Int]] checkAll("WriterT[ListWrapper, Int, Int]", kernel.laws.GroupLaws[WriterT[ListWrapper, Int, Int]].monoid) - Monoid[WriterT[Id, Int, Int]] - Semigroup[WriterT[Id, Int, Int]] + Monoid[Writer[Int, Int]] + checkAll("Writer[Int, Int]", kernel.laws.GroupLaws[Writer[Int, Int]].monoid) } { @@ -349,7 +348,8 @@ class WriterTTests extends CatsSuite { Semigroup[WriterT[ListWrapper, Int, Int]] checkAll("WriterT[ListWrapper, Int, Int]", kernel.laws.GroupLaws[WriterT[ListWrapper, Int, Int]].semigroup) - Semigroup[WriterT[Id, Int, Int]] + Semigroup[Writer[Int, Int]] + checkAll("Writer[Int, Int]", kernel.laws.GroupLaws[Writer[Int, Int]].semigroup) } {