diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/scala/async/run/anf/AnfTransformSpec.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala index f38efa9..f2fc2d7 100644 --- a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala +++ b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala @@ -54,8 +54,20 @@ class AnfTestClass { } z + 1 } + + def futureUnitIfElse(y: Int): Future[Unit] = async { + val f = base(y) + if (y > 0) { + State.result = await(f) + 2 + } else { + State.result = await(f) - 2 + } + } } +object State { + @volatile var result: Int = 0 +} @RunWith(classOf[JUnit4]) class AnfTransformSpec { @@ -91,4 +103,12 @@ class AnfTransformSpec { val res = Await.result(fut, 2 seconds) res mustBe (15) } + + @Test + def `Unit-typed if-else in tail position`() { + val o = new AnfTestClass + val fut = o.futureUnitIfElse(10) + Await.result(fut, 2 seconds) + State.result mustBe (14) + } } |