summaryrefslogtreecommitdiff
path: root/test/files/jvm/scala-concurrent-tck.scala
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2013-11-08 15:59:04 +0100
committerPhilipp Haller <hallerp@gmail.com>2013-11-12 20:15:49 +0100
commitaac015a84c2d64ce485078a5a854bc7533e2fc7b (patch)
treea892f2af1bd0c67490dcb6bfdb92d2c46e976749 /test/files/jvm/scala-concurrent-tck.scala
parent7ecfce1fb8d39275f082aaa3ad4dc0eee197391c (diff)
downloadscala-aac015a84c2d64ce485078a5a854bc7533e2fc7b.tar.gz
scala-aac015a84c2d64ce485078a5a854bc7533e2fc7b.tar.bz2
scala-aac015a84c2d64ce485078a5a854bc7533e2fc7b.zip
SI-7958 Deprecate methods `future` and `promise` in the `scala.concurrent` package object
- The corresponding `apply` methods in the `Future` and `Promise` objects should be used instead. - Adjusted tests to use non-deprecated versions - Fixed doc comments not to use deprecated methods - Added comment about planned removal in 2.13.0
Diffstat (limited to 'test/files/jvm/scala-concurrent-tck.scala')
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala116
1 files changed, 58 insertions, 58 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index 5006793084..b431f6b8f8 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -8,7 +8,7 @@ import scala.concurrent.{
CanAwait,
Await
}
-import scala.concurrent.{ future, promise, blocking }
+import scala.concurrent.blocking
import scala.util.{ Try, Success, Failure }
import scala.concurrent.duration.Duration
import scala.reflect.{ classTag, ClassTag }
@@ -35,14 +35,14 @@ trait FutureCallbacks extends TestBase {
def testOnSuccess(): Unit = once {
done =>
var x = 0
- val f = future { x = 1 }
+ val f = Future { x = 1 }
f onSuccess { case _ => done(x == 1) }
}
def testOnSuccessWhenCompleted(): Unit = once {
done =>
var x = 0
- val f = future { x = 1 }
+ val f = Future { x = 1 }
f onSuccess {
case _ if x == 1 =>
x = 2
@@ -52,21 +52,21 @@ trait FutureCallbacks extends TestBase {
def testOnSuccessWhenFailed(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception }
+ val f = Future[Unit] { throw new Exception }
f onSuccess { case _ => done(false) }
f onFailure { case _ => done(true) }
}
def testOnFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception }
+ val f = Future[Unit] { throw new Exception }
f onSuccess { case _ => done(false) }
f onFailure { case _ => done(true) }
}
def testOnFailureWhenSpecialThrowable(num: Int, cause: Throwable): Unit = once {
done =>
- val f = future[Unit] { throw cause }
+ val f = Future[Unit] { throw cause }
f onSuccess { case _ => done(false) }
f onFailure {
case e: ExecutionException if e.getCause == cause => done(true)
@@ -76,7 +76,7 @@ trait FutureCallbacks extends TestBase {
def testOnFailureWhenTimeoutException(): Unit = once {
done =>
- val f = future[Unit] { throw new TimeoutException() }
+ val f = Future[Unit] { throw new TimeoutException() }
f onSuccess { case _ => done(false) }
f onFailure {
case e: TimeoutException => done(true)
@@ -108,7 +108,7 @@ trait FutureCombinators extends TestBase {
def testMapSuccess(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f map { x => "result: " + x }
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -116,7 +116,7 @@ trait FutureCombinators extends TestBase {
def testMapFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception("exception message") }
+ val f = Future[Unit] { throw new Exception("exception message") }
val g = f map { x => "result: " + x }
g onSuccess { case _ => done(false) }
g onFailure { case t => done(t.getMessage() == "exception message") }
@@ -124,7 +124,7 @@ trait FutureCombinators extends TestBase {
def testMapSuccessPF(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f map { case r => "result: " + r }
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -132,7 +132,7 @@ trait FutureCombinators extends TestBase {
def testTransformSuccess(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f.transform(r => "result: " + r, identity)
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -140,7 +140,7 @@ trait FutureCombinators extends TestBase {
def testTransformSuccessPF(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f.transform( { case r => "result: " + r }, identity)
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -149,7 +149,7 @@ trait FutureCombinators extends TestBase {
def testTransformFailure(): Unit = once {
done =>
val transformed = new Exception("transformed")
- val f = future { throw new Exception("expected") }
+ val f = Future { throw new Exception("expected") }
val g = f.transform(identity, _ => transformed)
g onSuccess { case _ => done(false) }
g onFailure { case e => done(e eq transformed) }
@@ -159,7 +159,7 @@ def testTransformFailure(): Unit = once {
done =>
val e = new Exception("expected")
val transformed = new Exception("transformed")
- val f = future[Unit] { throw e }
+ val f = Future[Unit] { throw e }
val g = f.transform(identity, { case `e` => transformed })
g onSuccess { case _ => done(false) }
g onFailure { case e => done(e eq transformed) }
@@ -167,7 +167,7 @@ def testTransformFailure(): Unit = once {
def testFoldFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception("expected") }
+ val f = Future[Unit] { throw new Exception("expected") }
val g = f.transform(r => "result: " + r, identity)
g onSuccess { case _ => done(false) }
g onFailure { case t => done(t.getMessage() == "expected") }
@@ -175,23 +175,23 @@ def testTransformFailure(): Unit = once {
def testFlatMapSuccess(): Unit = once {
done =>
- val f = future { 5 }
- val g = f flatMap { _ => future { 10 } }
+ val f = Future { 5 }
+ val g = f flatMap { _ => Future { 10 } }
g onSuccess { case x => done(x == 10) }
g onFailure { case _ => done(false) }
}
def testFlatMapFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception("expected") }
- val g = f flatMap { _ => future { 10 } }
+ val f = Future[Unit] { throw new Exception("expected") }
+ val g = f flatMap { _ => Future { 10 } }
g onSuccess { case _ => done(false) }
g onFailure { case t => done(t.getMessage() == "expected") }
}
def testFilterSuccess(): Unit = once {
done =>
- val f = future { 4 }
+ val f = Future { 4 }
val g = f filter { _ % 2 == 0 }
g onSuccess { case x: Int => done(x == 4) }
g onFailure { case _ => done(false) }
@@ -199,7 +199,7 @@ def testTransformFailure(): Unit = once {
def testFilterFailure(): Unit = once {
done =>
- val f = future { 4 }
+ val f = Future { 4 }
val g = f filter { _ % 2 == 1 }
g onSuccess { case x: Int => done(false) }
g onFailure {
@@ -210,7 +210,7 @@ def testTransformFailure(): Unit = once {
def testCollectSuccess(): Unit = once {
done =>
- val f = future { -5 }
+ val f = Future { -5 }
val g = f collect { case x if x < 0 => -x }
g onSuccess { case x: Int => done(x == 5) }
g onFailure { case _ => done(false) }
@@ -218,7 +218,7 @@ def testTransformFailure(): Unit = once {
def testCollectFailure(): Unit = once {
done =>
- val f = future { -5 }
+ val f = Future { -5 }
val g = f collect { case x if x > 0 => x * 2 }
g onSuccess { case _ => done(false) }
g onFailure {
@@ -232,8 +232,8 @@ def testTransformFailure(): Unit = once {
def testForeachSuccess(): Unit = once {
done =>
- val p = promise[Int]()
- val f = future[Int] { 5 }
+ val p = Promise[Int]()
+ val f = Future[Int] { 5 }
f foreach { x => p.success(x * 2) }
val g = p.future
@@ -243,8 +243,8 @@ def testTransformFailure(): Unit = once {
def testForeachFailure(): Unit = once {
done =>
- val p = promise[Int]()
- val f = future[Int] { throw new Exception }
+ val p = Promise[Int]()
+ val f = Future[Int] { throw new Exception }
f foreach { x => p.success(x * 2) }
f onFailure { case _ => p.failure(new Exception) }
val g = p.future
@@ -256,7 +256,7 @@ def testTransformFailure(): Unit = once {
def testRecoverSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recover {
case re: RuntimeException =>
@@ -268,7 +268,7 @@ def testTransformFailure(): Unit = once {
def testRecoverFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recover {
case te: TimeoutException => "timeout"
@@ -280,11 +280,11 @@ def testTransformFailure(): Unit = once {
def testRecoverWithSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recoverWith {
case re: RuntimeException =>
- future { "recovered" }
+ Future { "recovered" }
}
f onSuccess { case x => done(x == "recovered") }
f onFailure { case any => done(false) }
@@ -293,11 +293,11 @@ def testTransformFailure(): Unit = once {
def testRecoverWithFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recoverWith {
case te: TimeoutException =>
- future { "timeout" }
+ Future { "timeout" }
}
f onSuccess { case x => done(false) }
f onFailure { case any => done(any == cause) }
@@ -305,8 +305,8 @@ def testTransformFailure(): Unit = once {
def testZipSuccess(): Unit = once {
done =>
- val f = future { 5 }
- val g = future { 6 }
+ val f = Future { 5 }
+ val g = Future { 6 }
val h = f zip g
h onSuccess { case (l: Int, r: Int) => done(l+r == 11) }
h onFailure { case _ => done(false) }
@@ -315,8 +315,8 @@ def testTransformFailure(): Unit = once {
def testZipFailureLeft(): Unit = once {
done =>
val cause = new Exception("expected")
- val f = future { throw cause }
- val g = future { 6 }
+ val f = Future { throw cause }
+ val g = Future { 6 }
val h = f zip g
h onSuccess { case _ => done(false) }
h onFailure { case e: Exception => done(e.getMessage == "expected") }
@@ -325,8 +325,8 @@ def testTransformFailure(): Unit = once {
def testZipFailureRight(): Unit = once {
done =>
val cause = new Exception("expected")
- val f = future { 5 }
- val g = future { throw cause }
+ val f = Future { 5 }
+ val g = Future { throw cause }
val h = f zip g
h onSuccess { case _ => done(false) }
h onFailure { case e: Exception => done(e.getMessage == "expected") }
@@ -334,8 +334,8 @@ def testTransformFailure(): Unit = once {
def testFallbackTo(): Unit = once {
done =>
- val f = future { sys.error("failed") }
- val g = future { 5 }
+ val f = Future { sys.error("failed") }
+ val g = Future { 5 }
val h = f fallbackTo g
h onSuccess { case x: Int => done(x == 5) }
h onFailure { case _ => done(false) }
@@ -344,8 +344,8 @@ def testTransformFailure(): Unit = once {
def testFallbackToFailure(): Unit = once {
done =>
val cause = new Exception
- val f = future { sys.error("failed") }
- val g = future { throw cause }
+ val f = Future { sys.error("failed") }
+ val g = Future { throw cause }
val h = f fallbackTo g
h onSuccess { case _ => done(false) }
@@ -382,7 +382,7 @@ trait FutureProjections extends TestBase {
def testFailedFailureOnComplete(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future { throw cause }
+ val f = Future { throw cause }
f.failed onComplete {
case Success(t) => done(t == cause)
case Failure(t) => done(false)
@@ -392,13 +392,13 @@ trait FutureProjections extends TestBase {
def testFailedFailureOnSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future { throw cause }
+ val f = Future { throw cause }
f.failed onSuccess { case t => done(t == cause) }
}
def testFailedSuccessOnComplete(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
f.failed onComplete {
case Failure(_: NoSuchElementException) => done(true)
case _ => done(false)
@@ -407,7 +407,7 @@ trait FutureProjections extends TestBase {
def testFailedSuccessOnFailure(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
f.failed onFailure {
case e: NoSuchElementException => done(true)
case _ => done(false)
@@ -418,13 +418,13 @@ trait FutureProjections extends TestBase {
def testFailedFailureAwait(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future { throw cause }
+ val f = Future { throw cause }
done(Await.result(f.failed, Duration(500, "ms")) == cause)
}
def testFailedSuccessAwait(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
try {
Await.result(f.failed, Duration(500, "ms"))
done(false)
@@ -437,7 +437,7 @@ trait FutureProjections extends TestBase {
def testAwaitPositiveDuration(): Unit = once { done =>
val p = Promise[Int]()
val f = p.future
- future {
+ Future {
intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) }
p.success(0)
Await.ready(f, Duration.Zero)
@@ -449,7 +449,7 @@ trait FutureProjections extends TestBase {
def testAwaitNegativeDuration(): Unit = once { done =>
val f = Promise().future
- future {
+ Future {
intercept[TimeoutException] { Await.ready(f, Duration.Zero) }
intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) }
intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) }
@@ -473,14 +473,14 @@ trait Blocking extends TestBase {
def testAwaitSuccess(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
done(Await.result(f, Duration(500, "ms")) == 0)
}
def testAwaitFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future { throw cause }
+ val f = Future { throw cause }
try {
Await.result(f, Duration(500, "ms"))
done(false)
@@ -562,7 +562,7 @@ trait Promises extends TestBase {
def testSuccess(): Unit = once {
done =>
- val p = promise[Int]()
+ val p = Promise[Int]()
val f = p.future
f onSuccess { case x => done(x == 5) }
@@ -574,7 +574,7 @@ trait Promises extends TestBase {
def testFailure(): Unit = once {
done =>
val e = new Exception("expected")
- val p = promise[Int]()
+ val p = Promise[Int]()
val f = p.future
f onSuccess { case x => done(false) }
@@ -644,7 +644,7 @@ trait CustomExecutionContext extends TestBase {
val count = countExecs { implicit ec =>
blocking {
once { done =>
- val f = future(assertNoEC())(defaultEC)
+ val f = Future(assertNoEC())(defaultEC)
f onSuccess {
case _ =>
assertEC()
@@ -749,14 +749,14 @@ trait ExecutionContextPrepare extends TestBase {
def testOnComplete(): Unit = once {
done =>
theLocal.set("secret")
- val fut = future { 42 }
+ val fut = Future { 42 }
fut onComplete { case _ => done(theLocal.get == "secret") }
}
def testMap(): Unit = once {
done =>
theLocal.set("secret2")
- val fut = future { 42 }
+ val fut = Future { 42 }
fut map { x => done(theLocal.get == "secret2") }
}