summaryrefslogtreecommitdiff
path: root/test/files/jvm/scala-concurrent-tck.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/jvm/scala-concurrent-tck.scala')
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala80
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)
}
+
+