summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/CheckEither.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-02-11 08:53:14 -0800
committerPaul Phillips <paulp@improving.org>2013-02-12 11:01:13 -0800
commitc26a8db067e4f04ef959bb9a8402fa3e931c3cd7 (patch)
tree8e920c4fd9ae5182c4175ca40d731dd36c004963 /test/files/scalacheck/CheckEither.scala
parent0c59fc9a1416cf5c45699111e8857adb03f7f0d4 (diff)
downloadscala-c26a8db067e4f04ef959bb9a8402fa3e931c3cd7.tar.gz
scala-c26a8db067e4f04ef959bb9a8402fa3e931c3cd7.tar.bz2
scala-c26a8db067e4f04ef959bb9a8402fa3e931c3cd7.zip
Maintenance of Predef.
1) Deprecates much of Predef and scala.Console, especially: - the read* methods (see below) - the set{Out,Err,In} methods (see SI-4793) 2) Removed long-deprecated: - Predef#exit - Predef#error should have gone, but could not due to sbt At least the whole source base has now been future-proofed against the eventual removal of Predef#error. The low justification for the read* methods should be readily apparent: they are little used and have no call to be in global namespace, especially given their weird ad hoc semantics and unreasonably tempting names such as readBoolean(). 3) Segregated the deprecated elements in Predef from the part which still thrives. 4) Converted all the standard Predef implicits into implicit classes, value classes where possible: - ArrowAssoc, Ensuring, StringFormat, StringAdd, RichException (value) - SeqCharSequence, ArrayCharSequence (non-value) Non-implicit deprecated stubs prop up the names of the formerly converting methods.
Diffstat (limited to 'test/files/scalacheck/CheckEither.scala')
-rw-r--r--test/files/scalacheck/CheckEither.scala28
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)
}