From ec030309937f3150625f5d12b9c1a1cf199848b2 Mon Sep 17 00:00:00 2001 From: phaller Date: Tue, 20 Nov 2012 17:26:44 +0100 Subject: Add negative tests for inlining blocks in ANF transform --- .../scala/async/neg/AnfTransformNegSpec.scala | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/test/scala/scala/async/neg/AnfTransformNegSpec.scala (limited to 'src/test') 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. + */ +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 + } + } +} -- cgit v1.2.3