From 5c86c44d2f170355ff7ff067edb02f345e9c91c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Rze=C5=BAnicki?= Date: Fri, 30 Dec 2016 15:56:04 +0100 Subject: [PATCH] Add missing tests for Either syntax --- .../test/scala/cats/tests/EitherTests.scala | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/src/test/scala/cats/tests/EitherTests.scala b/tests/src/test/scala/cats/tests/EitherTests.scala index 1f09f03140..6ba13df71f 100644 --- a/tests/src/test/scala/cats/tests/EitherTests.scala +++ b/tests/src/test/scala/cats/tests/EitherTests.scala @@ -255,4 +255,29 @@ class EitherTests extends CatsSuite { x.to[Option] should === (x.toOption) } } + + test("partialCompare consistent with PartialOrder") { + forAll { (x: Either[Int, String], y: Either[Int, String]) => + x.partialCompare(y) should === (partialOrder.partialCompare(x, y)) + } + } + + test("show Right") { + val either = Either.right[String, Int](10) + either.show should === ("Right(10)") + } + + test("show Left") { + val either = Either.left[String, Int]("string") + either.show should === ("Left(string)") + } + + test("ap consistent with Applicative") { + val fab = implicitly[Applicative[Either[String, ?]]] + forAll { (fa: Either[String, Int], + f: Int => String) => + fa.ap(Either.right(f)) should === (fab.map(fa)(f)) + } + } + }