diff options
Diffstat (limited to 'test/junit/scala/issues')
-rw-r--r-- | test/junit/scala/issues/BytecodeTest.scala | 8 | ||||
-rw-r--r-- | test/junit/scala/issues/OptimizedBytecodeTest.scala | 15 | ||||
-rw-r--r-- | test/junit/scala/issues/RunTest.scala | 11 |
3 files changed, 8 insertions, 26 deletions
diff --git a/test/junit/scala/issues/BytecodeTest.scala b/test/junit/scala/issues/BytecodeTest.scala index cf5c7f9ec3..a720f20718 100644 --- a/test/junit/scala/issues/BytecodeTest.scala +++ b/test/junit/scala/issues/BytecodeTest.scala @@ -15,15 +15,9 @@ import scala.tools.asm.tree.ClassNode import scala.tools.partest.ASMConverters._ import scala.tools.testing.ClearAfterClass -object BytecodeTest extends ClearAfterClass.Clearable { - var compiler = newCompiler() - def clear(): Unit = { compiler = null } -} - @RunWith(classOf[JUnit4]) class BytecodeTest extends ClearAfterClass { - ClearAfterClass.stateToClear = BytecodeTest - val compiler = BytecodeTest.compiler + val compiler = cached("compiler", () => newCompiler()) @Test def t8731(): Unit = { diff --git a/test/junit/scala/issues/OptimizedBytecodeTest.scala b/test/junit/scala/issues/OptimizedBytecodeTest.scala index 1555e8945a..c69229ae22 100644 --- a/test/junit/scala/issues/OptimizedBytecodeTest.scala +++ b/test/junit/scala/issues/OptimizedBytecodeTest.scala @@ -15,17 +15,10 @@ import AsmUtils._ import scala.tools.testing.ClearAfterClass -object OptimizedBytecodeTest extends ClearAfterClass.Clearable { - val args = "-Yopt:l:classpath -Yopt-warnings" - var compiler = newCompiler(extraArgs = args) - def clear(): Unit = { compiler = null } -} - @RunWith(classOf[JUnit4]) class OptimizedBytecodeTest extends ClearAfterClass { - ClearAfterClass.stateToClear = OptimizedBytecodeTest - - val compiler = OptimizedBytecodeTest.compiler + val args = "-Yopt:l:classpath -Yopt-warnings" + val compiler = cached("compiler", () => newCompiler(extraArgs = args)) @Test def t2171(): Unit = { @@ -127,7 +120,7 @@ class OptimizedBytecodeTest extends ClearAfterClass { |object Warmup { def filter[A](p: Any => Boolean): Any = filter[Any](p) } """.stripMargin val c2 = "class C { def t = warmup.Warmup.filter[Any](x => false) }" - val List(c, _, _) = compileClassesSeparately(List(c1, c2), extraArgs = OptimizedBytecodeTest.args) + val List(c, _, _) = compileClassesSeparately(List(c1, c2), extraArgs = args) assertInvoke(getSingleMethod(c, "t"), "warmup/Warmup$", "filter") } @@ -268,7 +261,7 @@ class OptimizedBytecodeTest extends ClearAfterClass { |} """.stripMargin - val cls = compileClassesSeparately(List(c1, c2), extraArgs = OptimizedBytecodeTest.args) + val cls = compileClassesSeparately(List(c1, c2), extraArgs = args) val c = cls.find(_.name == "C").get assertSameSummary(getSingleMethod(c, "t"), List( GETSTATIC, IFNONNULL, ACONST_NULL, ATHROW, // module load and null checks not yet eliminated diff --git a/test/junit/scala/issues/RunTest.scala b/test/junit/scala/issues/RunTest.scala index 0605947e63..148009c912 100644 --- a/test/junit/scala/issues/RunTest.scala +++ b/test/junit/scala/issues/RunTest.scala @@ -9,22 +9,17 @@ import scala.reflect.runtime._ import scala.tools.reflect.ToolBox import scala.tools.testing.ClearAfterClass -object RunTest extends ClearAfterClass.Clearable { - var toolBox = universe.runtimeMirror(getClass.getClassLoader).mkToolBox() - override def clear(): Unit = { toolBox = null } - - // definitions for individual tests +object RunTest { class VC(val x: Any) extends AnyVal } @RunWith(classOf[JUnit4]) class RunTest extends ClearAfterClass { - ClearAfterClass.stateToClear = RunTest + val toolBox = cached("toolbox", () => universe.runtimeMirror(getClass.getClassLoader).mkToolBox()) def run[T](code: String): T = { - val tb = RunTest.toolBox - tb.eval(tb.parse(code)).asInstanceOf[T] + toolBox.eval(toolBox.parse(code)).asInstanceOf[T] } @Test |