diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-04-03 10:17:33 +0200 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-04-03 10:17:33 +0200 |
commit | 457172dca3f3fea505f2421a99f86976141c7e75 (patch) | |
tree | d432670bceb25ea2dc751466612f782bcd587df9 /test/files/jvm | |
parent | 40334826eb573eed527cbd396ab406e7376edbcc (diff) | |
download | scala-457172dca3f3fea505f2421a99f86976141c7e75.tar.gz scala-457172dca3f3fea505f2421a99f86976141c7e75.tar.bz2 scala-457172dca3f3fea505f2421a99f86976141c7e75.zip |
Remedies Try/Either signature disparity for source compat. w/ Akka
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 80 |
1 files changed, 77 insertions, 3 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 75e2b92ff6..b3470d275d 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -1,6 +1,3 @@ - - - import scala.concurrent.{ Future, Promise, @@ -398,6 +395,80 @@ trait Exceptions extends TestBase { } +trait TryEitherExtractor extends TestBase { + + import scala.util.{Try, Success, Failure} + + def testSuccessMatch(): Unit = once { + done => + val thisIsASuccess = Success(42) + thisIsASuccess match { + case Success(v) => + done() + assert(v == 42) + case Failure(e) => + done() + assert(false) + case other => + done() + assert(false) + } + } + + def testRightMatch(): Unit = once { + done => + val thisIsNotASuccess: Right[Throwable, Int] = Right(43) + thisIsNotASuccess match { + case Success(v) => + done() + assert(v == 43) + case Failure(e) => + done() + assert(false) + case other => + done() + assert(false) + } + } + + def testFailureMatch(): Unit = once { + done => + val thisIsAFailure = Failure(new Exception("I'm an exception")) + thisIsAFailure match { + case Success(v) => + done() + assert(false) + case Failure(e) => + done() + assert(e.getMessage == "I'm an exception") + case other => + done() + assert(false) + } + } + + def testLeftMatch(): Unit = once { + done => + val thisIsNotAFailure: Left[Throwable, Int] = Left(new Exception("I'm an exception")) + thisIsNotAFailure match { + case Success(v) => + done() + assert(false) + case Failure(e) => + done() + assert(e.getMessage == "I'm an exception") + case other => + done() + assert(false) + } + + } + + testSuccessMatch() + testRightMatch() + testFailureMatch() + testLeftMatch() +} object Test extends App @@ -406,8 +477,11 @@ with FutureCombinators with FutureProjections with Promises with Exceptions +with TryEitherExtractor { System.exit(0) } + + |