diff options
Diffstat (limited to 'test/files/scalacheck/CheckEither.scala')
-rw-r--r-- | test/files/scalacheck/CheckEither.scala | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala index 4e8480d72e..4d0cab4693 100644 --- a/test/files/scalacheck/CheckEither.scala +++ b/test/files/scalacheck/CheckEither.scala @@ -8,18 +8,18 @@ import org.scalacheck.ConsoleReporter.testStatsEx import Function.tupled object Test extends Properties("Either") { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = + implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) - val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n) + val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => sys.error("fail")) == n) - val prop_either2 = forAll((n: Int) => Right(n).fold(a => error("fail"), x => x) == n) + val prop_either2 = forAll((n: Int) => Right(n).fold(a => sys.error("fail"), x => x) == n) val prop_swap = forAll((e: Either[Int, Int]) => e match { case Left(a) => e.swap.right.get == a case Right(b) => e.swap.left.get == b }) - + val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight) object CheckLeftProjection { @@ -35,7 +35,7 @@ object Test extends Properties("Either") { val prop_exists = forAll((e: Either[Int, Int]) => e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0)) - + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) Left(n).left.flatMap(f(_)) == f(n)}) @@ -115,7 +115,7 @@ object Test extends Properties("Either") { } val prop_Either_left = forAll((n: Int) => Left(n).left.get == n) - + val prop_Either_right = forAll((n: Int) => Right(n).right.get == n) val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match { @@ -128,12 +128,12 @@ object Test extends Properties("Either") { case Right(ee) => e.joinRight == ee }) - val prop_Either_reduce = forAll((e: Either[Int, Int]) => + val prop_Either_reduce = forAll((e: Either[Int, Int]) => e.merge == (e match { case Left(a) => a case Right(a) => a })) - + /** Hard to believe I'm "fixing" a test to reflect B before A ... */ val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) => Either.cond(c, a, b) == (if(c) Right(a) else Left(b))) @@ -168,19 +168,19 @@ object Test extends Properties("Either") { ("Right.prop_seq", CheckRightProjection.prop_seq), ("Right.prop_option", CheckRightProjection.prop_option), ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), + ("prop_Either_right", prop_Either_right), ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_reduce", prop_Either_reduce), + ("prop_Either_joinRight", prop_Either_joinRight), + ("prop_Either_reduce", prop_Either_reduce), ("prop_Either_cond", prop_Either_cond) ) - + for ((label, prop) <- tests) { property(label) = prop } - + import org.scalacheck.{ Test => STest } - + def runTests() = { STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) } |