From bc7f3d36b5b4cd132ce28baaa3c6db63b7f935a9 Mon Sep 17 00:00:00 2001 From: Vikraman Choudhury Date: Tue, 24 Nov 2015 04:26:21 -0500 Subject: [PATCH] Add tests for IdT --- .../scala/cats/laws/discipline/Arbitrary.scala | 3 +++ tests/src/test/scala/cats/tests/IdTTests.scala | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/src/test/scala/cats/tests/IdTTests.scala diff --git a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala index ee71f8d6aa8..a5cabdb8df2 100644 --- a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala +++ b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala @@ -38,6 +38,9 @@ object arbitrary extends ArbitraryInstances0 { implicit def optionTArbitrary[F[_], A](implicit F: Arbitrary[F[Option[A]]]): Arbitrary[OptionT[F, A]] = Arbitrary(F.arbitrary.map(OptionT.apply)) + implicit def idTArbitrary[F[_], A](implicit F: Arbitrary[F[A]]): Arbitrary[IdT[F, A]] = + Arbitrary(F.arbitrary.map(IdT.apply)) + implicit def evalArbitrary[A: Arbitrary]: Arbitrary[Eval[A]] = Arbitrary(Gen.oneOf( getArbitrary[A].map(Eval.now(_)), diff --git a/tests/src/test/scala/cats/tests/IdTTests.scala b/tests/src/test/scala/cats/tests/IdTTests.scala new file mode 100644 index 00000000000..0650956fa53 --- /dev/null +++ b/tests/src/test/scala/cats/tests/IdTTests.scala @@ -0,0 +1,16 @@ +package cats.tests + +import cats.{Monad, Traverse} +import cats.data.IdT +import cats.laws.discipline.{MonadTests, SerializableTests, TraverseTests} +import cats.laws.discipline.arbitrary._ + +class IdTTests extends CatsSuite { + + checkAll("IdT[List, Int]", MonadTests[IdT[List, ?]].monad[Int, Int, Int]) + checkAll("Monad[IdT[List, ?]]", SerializableTests.serializable(Monad[IdT[List, ?]])) + + checkAll("IdT[List, Int]", TraverseTests[IdT[List, ?]].traverse[Int, Int, Int, Int, List, List]) + checkAll("Traverse[IdT[List, ?]]", SerializableTests.serializable(Traverse[IdT[List, ?]])) + +}