summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-05-16 16:04:17 +1000
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-16 08:04:17 +0200
commiteac1af364e99a6712c5e54e257216027b2ab127e (patch)
tree7913340cff137466511c3d6ca4066fdd55d4aeb9 /test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
parent9e30bee0c9363f6cf36a7b65ddbaaa225b57d6a9 (diff)
downloadscala-eac1af364e99a6712c5e54e257216027b2ab127e.tar.gz
scala-eac1af364e99a6712c5e54e257216027b2ab127e.tar.bz2
scala-eac1af364e99a6712c5e54e257216027b2ab127e.zip
Reduce boilerplate in compiler JUnit tests (#5158)
Many JUnit tests share a compiler instance between all test cases in a class to reduce overhead. This commit refactors the mechanism to reduce the boilerplate. In the new scheme: - Using the `@ClassRule` hook in JUnit, we create a per-class map for each test class. - Per-class values are registered from the test class itself by calling `cached("someKey", () => mkExpensiveThing)` - At the end of the test, the entries in this map are `close()`-ed (if they implement `Closable`), and are released for garbage collection.)
Diffstat (limited to 'test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala')
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala9
1 files changed, 1 insertions, 8 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
index dd7fbd9977..003b2d4880 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
@@ -18,16 +18,9 @@ import ASMConverters._
import scala.tools.testing.ClearAfterClass
import scala.collection.JavaConverters._
-object MethodLevelOptsTest extends ClearAfterClass.Clearable {
- var methodOptCompiler = newCompiler(extraArgs = "-Yopt:l:method")
- def clear(): Unit = { methodOptCompiler = null }
-}
-
@RunWith(classOf[JUnit4])
class MethodLevelOptsTest extends ClearAfterClass {
- ClearAfterClass.stateToClear = MethodLevelOptsTest
-
- val methodOptCompiler = MethodLevelOptsTest.methodOptCompiler
+ val methodOptCompiler = cached("methodOptCompiler", () => newCompiler(extraArgs = "-Yopt:l:method"))
def wrapInDefault(code: Instruction*) = List(Label(0), LineNumber(1, Label(0))) ::: code.toList ::: List(Label(1))