diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-07-21 12:40:37 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-07-21 15:45:52 +0200 |
commit | de102789917e4b9aeae2836bde70c2a8c29a7e0e (patch) | |
tree | 88338e5ada77918fc9cb251e626aec406722779f /src/test/scala | |
parent | a08a822df9987bf34ec804f0e5a537da75fd3294 (diff) | |
parent | 154a2d7d7fab1b6db940a01c212c8de0138ae930 (diff) | |
download | scala-async-de102789917e4b9aeae2836bde70c2a8c29a7e0e.tar.gz scala-async-de102789917e4b9aeae2836bde70c2a8c29a7e0e.tar.bz2 scala-async-de102789917e4b9aeae2836bde70c2a8c29a7e0e.zip |
Merge remote-tracking branch 'origin/2.10.x' into merge/2.10.x-to-master-20140721
Conflicts:
src/main/scala/scala/async/internal/AsyncTransform.scala
src/main/scala/scala/async/internal/Lifter.scala
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/scala/async/run/ifelse1/IfElse1.scala | 77 | ||||
-rw-r--r-- | src/test/scala/scala/async/run/ifelse4/IfElse4.scala | 63 | ||||
-rw-r--r-- | src/test/scala/scala/async/run/toughtype/ToughType.scala | 16 |
3 files changed, 156 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/ifelse1/IfElse1.scala b/src/test/scala/scala/async/run/ifelse1/IfElse1.scala index 587aaac..6cbe910 100644 --- a/src/test/scala/scala/async/run/ifelse1/IfElse1.scala +++ b/src/test/scala/scala/async/run/ifelse1/IfElse1.scala @@ -87,6 +87,75 @@ class TestIfElse1Class { } z } + + def pred: Future[Boolean] = async(true) + + def m5: Future[Boolean] = async { + if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(if(await(pred)) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false) + await(pred) + else + false + } } class IfElse1Spec { @@ -124,4 +193,12 @@ class IfElse1Spec { val res = Await.result(fut, 2 seconds) res mustBe (14) } + + @Test + def `await in deeply-nested if-else conditions`() { + val o = new TestIfElse1Class + val fut = o.m5 + val res = Await.result(fut, 2 seconds) + res mustBe true + } } diff --git a/src/test/scala/scala/async/run/ifelse4/IfElse4.scala b/src/test/scala/scala/async/run/ifelse4/IfElse4.scala new file mode 100644 index 0000000..b0ecf13 --- /dev/null +++ b/src/test/scala/scala/async/run/ifelse4/IfElse4.scala @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com> + */ + +package scala.async +package run +package ifelse4 + +import language.{reflectiveCalls, postfixOps} +import scala.concurrent.{Future, ExecutionContext, future, Await} +import scala.concurrent.duration._ +import scala.async.Async.{async, await} +import org.junit.Test + + +class TestIfElse4Class { + + import ExecutionContext.Implicits.global + + class F[A] + class S[A](val id: String) + trait P + + case class K(f: F[_]) + + def result[A](f: F[A]) = async { + new S[A with P]("foo") + } + + def run(k: K) = async { + val res = await(result(k.f)) + // these triggered a crash with mismatched existential skolems + // found : S#10272[_$1#10308 with String#137] where type _$1#10308 + // required: S#10272[_$1#10311 with String#137] forSome { type _$1#10311 } + + // This variation of the crash could be avoided by fixing the over-eager + // generation of states in `If` nodes, which was caused by a bug in label + // detection code. + if(true) { + identity(res) + } + + // This variation remained after the aforementioned fix, however. + // It was fixed by manually typing the `Assign(liftedField, rhs)` AST, + // which is how we avoid these problems through the rest of the ANF transform. + if(true) { + identity(res) + await(result(k.f)) + } + res + } +} + +class IfElse4Spec { + + @Test + def `await result with complex type containing skolem`() { + val o = new TestIfElse4Class + val fut = o.run(new o.K(null)) + val res = Await.result(fut, 2 seconds) + res.id mustBe ("foo") + } +} diff --git a/src/test/scala/scala/async/run/toughtype/ToughType.scala b/src/test/scala/scala/async/run/toughtype/ToughType.scala index 458157c..54a53c8 100644 --- a/src/test/scala/scala/async/run/toughtype/ToughType.scala +++ b/src/test/scala/scala/async/run/toughtype/ToughType.scala @@ -211,6 +211,22 @@ class ToughTypeSpec { }(SomeExecutionContext) } } + + } + + @Test def ticket66Nothing() { + import scala.concurrent.Future + import scala.concurrent.ExecutionContext.Implicits.global + val e = new Exception() + val f: Future[Nothing] = Future.failed(e) + val f1 = async { + await(f) + } + try { + Await.result(f1, 5.seconds) + } catch { + case `e` => + } } } |