summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
authorViktor Klang <viktor.klang@gmail.com>2013-05-08 15:49:13 +0200
committerViktor Klang <viktor.klang@gmail.com>2013-05-10 00:18:51 +0200
commitb32d294e14615bea0c062dd61350f8ab6a05b8dc (patch)
treec504926ef9751dd4ec1119a747ce55daab275103 /test/files/jvm
parent5c77e01794434b2fa01a1bd250c08198c31796e3 (diff)
downloadscala-b32d294e14615bea0c062dd61350f8ab6a05b8dc.tar.gz
scala-b32d294e14615bea0c062dd61350f8ab6a05b8dc.tar.bz2
scala-b32d294e14615bea0c062dd61350f8ab6a05b8dc.zip
SI-7383 - Call ExecutionContext.prepare in Future.apply to allow for capturing local context like ThreadLocals and then re-establishing them prior to execution, as per intention of EC.prepare
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index 0efa83fbd9..ddd819c109 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -71,6 +71,25 @@ object FutureTests extends MinimalScalaTest {
}
}
+ "The Future companion object" should {
+ "call ExecutionContext.prepare on apply" in {
+ val p = Promise[Boolean]()
+ val ec = new ExecutionContext {
+ val delegate = ExecutionContext.global
+ override def prepare(): ExecutionContext = {
+ p.success(true)
+ delegate.prepare
+ }
+ override def execute(r: Runnable) = delegate.execute(r)
+ override def reportFailure(t: Throwable): Unit = delegate.reportFailure(t)
+ }
+
+ val f = Future("foo")(ec)
+ Await.result(f, defaultTimeout) mustBe ("foo")
+ Await.result(p.future, defaultTimeout) mustBe (true)
+ }
+ }
+
"The default ExecutionContext" should {
"report uncaught exceptions" in {
val p = Promise[Throwable]()