summaryrefslogtreecommitdiff
path: root/test/files/jvm/future-spec
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/future-spec
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/future-spec')
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala46
1 files changed, 23 insertions, 23 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index 1595b2c862..cfdcc31ac5 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -15,7 +15,7 @@ class FutureTests extends MinimalScalaTest {
/* some utils */
def testAsync(s: String)(implicit ec: ExecutionContext): Future[String] = s match {
- case "Hello" => future { "World" }
+ case "Hello" => Future { "World" }
case "Failure" => Future.failed(new RuntimeException("Expected exception; to test fault-tolerance"))
case "NoReply" => Promise[String]().future
}
@@ -34,7 +34,7 @@ class FutureTests extends MinimalScalaTest {
class ThrowableTest(m: String) extends Throwable(m)
- val f1 = future[Any] {
+ val f1 = Future[Any] {
throw new ThrowableTest("test")
}
@@ -43,7 +43,7 @@ class FutureTests extends MinimalScalaTest {
}
val latch = new TestLatch
- val f2 = future {
+ val f2 = Future {
Await.ready(latch, 5 seconds)
"success"
}
@@ -61,7 +61,7 @@ class FutureTests extends MinimalScalaTest {
Await.result(f3, defaultTimeout) mustBe ("SUCCESS")
- val waiting = future {
+ val waiting = Future {
Thread.sleep(1000)
}
Await.ready(waiting, 2000 millis)
@@ -106,8 +106,8 @@ class FutureTests extends MinimalScalaTest {
import ExecutionContext.Implicits._
"compose with for-comprehensions" in {
- def async(x: Int) = future { (x * 2).toString }
- val future0 = future[Any] {
+ def async(x: Int) = Future { (x * 2).toString }
+ val future0 = Future[Any] {
"five!".length
}
@@ -119,8 +119,8 @@ class FutureTests extends MinimalScalaTest {
val future2 = for {
a <- future0.mapTo[Int]
- b <- (future { (a * 2).toString }).mapTo[Int]
- c <- future { (7 * 2).toString }
+ b <- (Future { (a * 2).toString }).mapTo[Int]
+ c <- Future { (7 * 2).toString }
} yield b + "-" + c
Await.result(future1, defaultTimeout) mustBe ("10-14")
@@ -132,8 +132,8 @@ class FutureTests extends MinimalScalaTest {
case class Req[T](req: T)
case class Res[T](res: T)
def async[T](req: Req[T]) = req match {
- case Req(s: String) => future { Res(s.length) }
- case Req(i: Int) => future { Res((i * 2).toString) }
+ case Req(s: String) => Future { Res(s.length) }
+ case Req(i: Int) => Future { Res((i * 2).toString) }
}
val future1 = for {
@@ -224,7 +224,7 @@ class FutureTests extends MinimalScalaTest {
"andThen like a boss" in {
val q = new java.util.concurrent.LinkedBlockingQueue[Int]
for (i <- 1 to 1000) {
- val chained = future {
+ val chained = Future {
q.add(1); 3
} andThen {
case _ => q.add(2)
@@ -251,7 +251,7 @@ class FutureTests extends MinimalScalaTest {
}
"find" in {
- val futures = for (i <- 1 to 10) yield future {
+ val futures = for (i <- 1 to 10) yield Future {
i
}
@@ -286,7 +286,7 @@ class FutureTests extends MinimalScalaTest {
"fold" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
add
}
@@ -306,7 +306,7 @@ class FutureTests extends MinimalScalaTest {
"fold by composing" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
add
}
@@ -321,7 +321,7 @@ class FutureTests extends MinimalScalaTest {
"fold with an exception" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
add
@@ -357,7 +357,7 @@ class FutureTests extends MinimalScalaTest {
}
"shouldReduceResults" in {
- def async(idx: Int) = future {
+ def async(idx: Int) = Future {
Thread.sleep(idx * 20)
idx
}
@@ -373,7 +373,7 @@ class FutureTests extends MinimalScalaTest {
}
"shouldReduceResultsWithException" in {
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
else add
@@ -404,7 +404,7 @@ class FutureTests extends MinimalScalaTest {
}
}
- val oddFutures = List.fill(100)(future { counter.incAndGet() }).iterator
+ val oddFutures = List.fill(100)(Future { counter.incAndGet() }).iterator
val traversed = Future.sequence(oddFutures)
Await.result(traversed, defaultTimeout).sum mustBe (10000)
@@ -420,11 +420,11 @@ class FutureTests extends MinimalScalaTest {
"shouldBlockUntilResult" in {
val latch = new TestLatch
- val f = future {
+ val f = Future {
Await.ready(latch, 5 seconds)
5
}
- val f2 = future {
+ val f2 = Future {
val res = Await.result(f, Inf)
res + 9
}
@@ -437,7 +437,7 @@ class FutureTests extends MinimalScalaTest {
Await.result(f2, defaultTimeout) mustBe (14)
- val f3 = future {
+ val f3 = Future {
Thread.sleep(100)
5
}
@@ -450,7 +450,7 @@ class FutureTests extends MinimalScalaTest {
"run callbacks async" in {
val latch = Vector.fill(10)(new TestLatch)
- val f1 = future {
+ val f1 = Future {
latch(0).open()
Await.ready(latch(1), TestLatch.DefaultTimeout)
"Hello"
@@ -542,7 +542,7 @@ class FutureTests extends MinimalScalaTest {
"should not throw when Await.ready" in {
val expected = try Success(5 / 0) catch { case a: ArithmeticException => Failure(a) }
- val f = future(5).map(_ / 0)
+ val f = Future(5).map(_ / 0)
Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString
}