diff options
Diffstat (limited to 'test/files/jvm/scala-concurrent-tck.scala')
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 5c9c71f3f8..43d4c9dc71 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -4,7 +4,9 @@ import scala.concurrent.{ TimeoutException, SyncVar, ExecutionException, - ExecutionContext + ExecutionContext, + CanAwait, + Await } import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } @@ -647,7 +649,7 @@ trait FutureProjections extends TestBase { val f = future { throw cause } - assert(blocking(f.failed, Duration(500, "ms")) == cause) + assert(Await.result(f.failed, Duration(500, "ms")) == cause) done() } @@ -655,7 +657,7 @@ trait FutureProjections extends TestBase { done => val f = future { 0 } try { - blocking(f.failed, Duration(500, "ms")) + Await.result(f.failed, Duration(500, "ms")) assert(false) } catch { case nsee: NoSuchElementException => done() @@ -678,7 +680,7 @@ trait Blocking extends TestBase { def testAwaitSuccess(): Unit = once { done => val f = future { 0 } - blocking(f, Duration(500, "ms")) + Await.result(f, Duration(500, "ms")) done() } @@ -689,7 +691,7 @@ trait Blocking extends TestBase { throw cause } try { - blocking(f, Duration(500, "ms")) + Await.result(f, Duration(500, "ms")) assert(false) } catch { case t => @@ -698,9 +700,18 @@ trait Blocking extends TestBase { } } + def testFQCNForAwaitAPI(): Unit = once { + done => + + assert(classOf[CanAwait].getName == "scala.concurrent.CanAwait") + assert(Await.getClass.getName == "scala.concurrent.Await") + + done() + } + testAwaitSuccess() testAwaitFailure() - + testFQCNForAwaitAPI() } trait BlockContexts extends TestBase { @@ -708,7 +719,7 @@ trait BlockContexts extends TestBase { import scala.concurrent.{ Await, Awaitable, BlockContext } private def getBlockContext(body: => BlockContext): BlockContext = { - blocking(Future { body }, Duration(500, "ms")) + Await.result(Future { body }, Duration(500, "ms")) } // test outside of an ExecutionContext @@ -727,8 +738,7 @@ trait BlockContexts extends TestBase { def testPushCustom(): Unit = { val orig = BlockContext.current val customBC = new BlockContext() { - override def internalBlockingCall[T](awaitable: Awaitable[T], atMost: Duration): T = - orig.internalBlockingCall(awaitable, atMost) + override def blockOn[T](thunk: =>T)(implicit permission: CanAwait): T = orig.blockOn(thunk) } val bc = getBlockContext({ @@ -744,8 +754,7 @@ trait BlockContexts extends TestBase { def testPopCustom(): Unit = { val orig = BlockContext.current val customBC = new BlockContext() { - override def internalBlockingCall[T](awaitable: Awaitable[T], atMost: Duration): T = - orig.internalBlockingCall(awaitable, atMost) + override def blockOn[T](thunk: =>T)(implicit permission: CanAwait): T = orig.blockOn(thunk) } val bc = getBlockContext({ |