diff options
author | phaller <hallerp@gmail.com> | 2012-11-20 17:26:44 +0100 |
---|---|---|
committer | phaller <hallerp@gmail.com> | 2012-11-20 17:26:44 +0100 |
commit | ec030309937f3150625f5d12b9c1a1cf199848b2 (patch) | |
tree | 035511470e687368cce97eb18cfbfcf65aacf555 /src | |
parent | 92717bda882903dca427cf95f83fcfde9e0d2322 (diff) | |
download | scala-async-ec030309937f3150625f5d12b9c1a1cf199848b2.tar.gz scala-async-ec030309937f3150625f5d12b9c1a1cf199848b2.tar.bz2 scala-async-ec030309937f3150625f5d12b9c1a1cf199848b2.zip |
Add negative tests for inlining blocks in ANF transform
Diffstat (limited to 'src')
-rw-r--r-- | src/test/scala/scala/async/neg/AnfTransformNegSpec.scala | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/neg/AnfTransformNegSpec.scala b/src/test/scala/scala/async/neg/AnfTransformNegSpec.scala new file mode 100644 index 0000000..974a5f1 --- /dev/null +++ b/src/test/scala/scala/async/neg/AnfTransformNegSpec.scala @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com> + */ +package scala.async +package neg + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test + +@RunWith(classOf[JUnit4]) +class AnfTransformNegSpec { + + @Test + def `inlining block produces duplicate definition`() { + expectError("x is already defined as value x", "-cp target/scala-2.10/classes -deprecation -Xfatal-warnings") { + """ + | import scala.concurrent.ExecutionContext.Implicits.global + | import scala.concurrent.Future + | import scala.async.Async._ + | + | async { + | val f = Future { 12 } + | val x = await(f) + | + | { + | val x = 42 + | println(x) + | } + | + | x + | } + """.stripMargin + } + } + + @Test + def `inlining block in tail position produces duplicate definition`() { + expectError("x is already defined as value x", "-cp target/scala-2.10/classes -deprecation -Xfatal-warnings") { + """ + | import scala.concurrent.ExecutionContext.Implicits.global + | import scala.concurrent.Future + | import scala.async.Async._ + | + | async { + | val f = Future { 12 } + | val x = await(f) + | + | { + | val x = 42 + | x + | } + | } + """.stripMargin + } + } +} |