Skip to content

Commit

Permalink
Add missing tests for Either syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-rzeznicki committed Dec 30, 2016
1 parent d084def commit 5c86c44
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/src/test/scala/cats/tests/EitherTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

}

0 comments on commit 5c86c44

Please sign in to comment.