diff options
author | Viktor Klang <viktor.klang@gmail.com> | 2013-05-08 15:49:13 +0200 |
---|---|---|
committer | Viktor Klang <viktor.klang@gmail.com> | 2013-05-10 00:18:51 +0200 |
commit | b32d294e14615bea0c062dd61350f8ab6a05b8dc (patch) | |
tree | c504926ef9751dd4ec1119a747ce55daab275103 /test/files/jvm | |
parent | 5c77e01794434b2fa01a1bd250c08198c31796e3 (diff) | |
download | scala-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.scala | 19 |
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]() |