aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/neg
diff options
context:
space:
mode:
authorphaller <hallerp@gmail.com>2012-11-20 17:26:44 +0100
committerphaller <hallerp@gmail.com>2012-11-20 17:26:44 +0100
commitec030309937f3150625f5d12b9c1a1cf199848b2 (patch)
tree035511470e687368cce97eb18cfbfcf65aacf555 /src/test/scala/scala/async/neg
parent92717bda882903dca427cf95f83fcfde9e0d2322 (diff)
downloadscala-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/test/scala/scala/async/neg')
-rw-r--r--src/test/scala/scala/async/neg/AnfTransformNegSpec.scala57
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
+ }
+ }
+}