summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/collection/mutable/OpenHashMapTest.scala58
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/BTypesTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/OptimizedBytecodeTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/AnalyzerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/ClosureOptimizerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala4
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala4
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlineInfoTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala10
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerSeparateCompilationTest.scala4
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala8
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala6
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/UnusedLocalVariablesTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala19
-rw-r--r--test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala2
23 files changed, 109 insertions, 34 deletions
diff --git a/test/junit/scala/collection/mutable/OpenHashMapTest.scala b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
index 9b5c20e01a..b6cddf2101 100644
--- a/test/junit/scala/collection/mutable/OpenHashMapTest.scala
+++ b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
@@ -4,6 +4,10 @@ import org.junit.Test
import org.junit.Assert._
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import org.openjdk.jol.info.GraphLayout
+import org.openjdk.jol.info.GraphWalker
+import org.openjdk.jol.info.GraphVisitor
+import org.openjdk.jol.info.GraphPathRecord
/** Tests for [[OpenHashMap]]. */
@RunWith(classOf[JUnit4])
@@ -28,7 +32,13 @@ class OpenHashMapTest {
val fieldMirror = mirror.reflect(m).reflectField(termSym)
*/
// Use Java reflection instead for now.
- val field = m.getClass.getDeclaredField("deleted")
+ val field =
+ try { // Name may or not be mangled, depending on what the compiler authors are doing.
+ m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted")
+ } catch {
+ case _: NoSuchFieldException =>
+ m.getClass.getDeclaredField("deleted")
+ }
field.setAccessible(true)
m.put(0, 0)
@@ -39,4 +49,50 @@ class OpenHashMapTest {
// TODO assertEquals(0, fieldMirror.get.asInstanceOf[Int])
assertEquals(0, field.getInt(m))
}
+
+ /** Test that an [[OpenHashMap]] frees references to a deleted key (SI-9522). */
+ @Test
+ def freesDeletedKey {
+ import scala.language.reflectiveCalls
+
+ class MyClass {
+ override def hashCode() = 42
+ }
+
+ val counter = new GraphVisitor() {
+ private[this] var instanceCount: Int = _
+
+ def countInstances(obj: AnyRef) = {
+ instanceCount = 0
+ val walker = new GraphWalker(obj)
+ walker.addVisitor(this)
+ walker.walk
+ instanceCount
+ }
+
+ override def visit(record: GraphPathRecord) {
+ if (record.klass() == classOf[MyClass]) instanceCount += 1
+ }
+ }
+
+ val m = OpenHashMap.empty[MyClass, Int]
+ val obj = new MyClass
+ assertEquals("Found a key instance in the map before adding one!?", 0, counter.countInstances(m))
+ m.put(obj, 0)
+ assertEquals("There should be only one key instance in the map.", 1, counter.countInstances(m))
+ m.put(obj, 1)
+ assertEquals("There should still be only one key instance in the map.", 1, counter.countInstances(m))
+ m.remove(obj)
+ assertEquals("There should be no key instance in the map.", 0, counter.countInstances(m))
+
+ val obj2 = new MyClass
+ assertEquals("The hash codes of the test objects need to match.", obj.##, obj2.##)
+ m.put(obj, 0)
+ m.put(obj2, 0)
+ assertEquals("There should be two key instances in the map.", 2, counter.countInstances(m))
+ m.remove(obj)
+ assertEquals("There should be one key instance in the map.", 1, counter.countInstances(m))
+ m.remove(obj2)
+ assertEquals("There should be no key instance in the map.", 0, counter.countInstances(m))
+ }
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/BTypesTest.scala b/test/junit/scala/tools/nsc/backend/jvm/BTypesTest.scala
index 0144fa7366..58df4691e4 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/BTypesTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/BTypesTest.scala
@@ -11,7 +11,7 @@ import scala.tools.testing.BytecodeTesting
@RunWith(classOf[JUnit4])
class BTypesTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler.global
locally {
new global.Run() // initializes some of the compiler
diff --git a/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala b/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
index 7fdfb31577..f835e9b140 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
@@ -12,7 +12,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class DirectCompileTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:method"
+ override def compilerArgs = "-opt:l:method"
import compiler._
@Test
diff --git a/test/junit/scala/tools/nsc/backend/jvm/OptimizedBytecodeTest.scala b/test/junit/scala/tools/nsc/backend/jvm/OptimizedBytecodeTest.scala
index 003162c1ad..8cf6a655d2 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/OptimizedBytecodeTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/OptimizedBytecodeTest.scala
@@ -11,7 +11,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class OptimizedBytecodeTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:classpath -Yopt-warnings"
+ override def compilerArgs = "-opt:l:classpath -opt-warnings"
import compiler._
@Test
diff --git a/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala
index b0a86dfd28..1de5aa28ca 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala
@@ -17,7 +17,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class NullnessAnalyzerTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler._
import global.genBCode.bTypes.backendUtils._
diff --git a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala
index fc26785237..8cb04822de 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala
@@ -16,7 +16,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class ProdConsAnalyzerTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler._
import global.genBCode.bTypes.backendUtils._
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/AnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/AnalyzerTest.scala
index 025248ac28..33ca6a5fd2 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/AnalyzerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/AnalyzerTest.scala
@@ -15,7 +15,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class AnalyzerTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler._
@Test
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala
index e7aea71e72..c23c60f7ad 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/BTypesFromClassfileTest.scala
@@ -14,7 +14,7 @@ import scala.tools.testing.BytecodeTesting
@RunWith(classOf[JUnit4])
class BTypesFromClassfileTest extends BytecodeTesting {
// inliner enabled -> inlineInfos are collected (and compared) in ClassBTypes
- override def compilerArgs = "-Yopt:inline-global"
+ override def compilerArgs = "-opt:inline-global"
import compiler.global._
import definitions._
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala
index 630416a925..80fbba133e 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala
@@ -18,7 +18,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class CallGraphTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:inline-global -Yopt-warnings"
+ override def compilerArgs = "-opt:inline-global -opt-warnings"
import compiler._
import global.genBCode.bTypes
val notPerRun: List[Clearable] = List(
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/ClosureOptimizerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/ClosureOptimizerTest.scala
index 218b02f822..2da2ecdb72 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/ClosureOptimizerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/ClosureOptimizerTest.scala
@@ -13,7 +13,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class ClosureOptimizerTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:classpath -Yopt-warnings:_"
+ override def compilerArgs = "-opt:l:classpath -opt-warnings:_"
import compiler._
@Test
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala
index c3748a05bd..6f54f170b5 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala
@@ -15,8 +15,8 @@ import scala.tools.testing.ClearAfterClass
class CompactLocalVariablesTest extends ClearAfterClass {
// recurse-unreachable-jumps is required for eliminating catch blocks, in the first dce round they
// are still live.only after eliminating the empty handler the catch blocks become unreachable.
- val methodOptCompiler = cached("methodOptCompiler", () => newCompiler(extraArgs = "-Yopt:unreachable-code,compact-locals"))
- val noCompactVarsCompiler = cached("noCompactVarsCompiler", () => newCompiler(extraArgs = "-Yopt:unreachable-code"))
+ val methodOptCompiler = cached("methodOptCompiler", () => newCompiler(extraArgs = "-opt:unreachable-code,compact-locals"))
+ val noCompactVarsCompiler = cached("noCompactVarsCompiler", () => newCompiler(extraArgs = "-opt:unreachable-code"))
@Test
def compactUnused(): Unit = {
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
index 3324058cb7..77215304fd 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
@@ -15,10 +15,10 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class EmptyExceptionHandlersTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:unreachable-code"
+ override def compilerArgs = "-opt:unreachable-code"
def dceCompiler = compiler
- val noOptCompiler = cached("noOptCompiler", () => newCompiler(extraArgs = "-Yopt:l:none"))
+ val noOptCompiler = cached("noOptCompiler", () => newCompiler(extraArgs = "-opt:l:none"))
val exceptionDescriptor = "java/lang/Exception"
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineInfoTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineInfoTest.scala
index e45d7139a3..a691d63471 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineInfoTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineInfoTest.scala
@@ -16,7 +16,7 @@ class InlineInfoTest extends BytecodeTesting {
import compiler.global
import global.genBCode.bTypes
- override def compilerArgs = "-Yopt:l:classpath"
+ override def compilerArgs = "-opt:l:classpath"
def notPerRun: List[Clearable] = List(
bTypes.classBTypeFromInternalName,
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala
index f0913f3631..6161dc7b73 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala
@@ -11,12 +11,12 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class InlineWarningTest extends BytecodeTesting {
- def optCp = "-Yopt:l:classpath"
- override def compilerArgs = s"$optCp -Yopt-warnings"
+ def optCp = "-opt:l:classpath"
+ override def compilerArgs = s"$optCp -opt-warnings"
import compiler._
- val compilerWarnAll = cached("compilerWarnAll", () => newCompiler(extraArgs = s"$optCp -Yopt-warnings:_"))
+ val compilerWarnAll = cached("compilerWarnAll", () => newCompiler(extraArgs = s"$optCp -opt-warnings:_"))
@Test
def nonFinal(): Unit = {
@@ -87,10 +87,10 @@ class InlineWarningTest extends BytecodeTesting {
assert(c == 1, c)
// no warnings here
- newCompiler(extraArgs = s"$optCp -Yopt-warnings:none").compileToBytes(scalaCode, List((javaCode, "A.java")))
+ newCompiler(extraArgs = s"$optCp -opt-warnings:none").compileToBytes(scalaCode, List((javaCode, "A.java")))
c = 0
- newCompiler(extraArgs = s"$optCp -Yopt-warnings:no-inline-mixed").compileToBytes(scalaCode, List((javaCode, "A.java")), allowMessage = i => {c += 1; warns.exists(i.msg contains _)})
+ newCompiler(extraArgs = s"$optCp -opt-warnings:no-inline-mixed").compileToBytes(scalaCode, List((javaCode, "A.java")), allowMessage = i => {c += 1; warns.exists(i.msg contains _)})
assert(c == 2, c)
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
index c2ada8afec..3cb1fbdae6 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
@@ -14,7 +14,7 @@ import scala.tools.testing.BytecodeTesting
@RunWith(classOf[JUnit4])
class InlinerIllegalAccessTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler._
import global.genBCode.bTypes._
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerSeparateCompilationTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerSeparateCompilationTest.scala
index b196f1a9ba..a2513cacdc 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerSeparateCompilationTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerSeparateCompilationTest.scala
@@ -10,7 +10,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class InlinerSeparateCompilationTest {
- val args = "-Yopt:l:classpath"
+ val args = "-opt:l:classpath"
@Test
def inlnieMixedinMember(): Unit = {
@@ -32,7 +32,7 @@ class InlinerSeparateCompilationTest {
""".stripMargin
val warn = "T::f()I is annotated @inline but cannot be inlined: the method is not final and may be overridden"
- val List(c, o, oMod, t) = compileClassesSeparately(List(codeA, codeB), args + " -Yopt-warnings", _.msg contains warn)
+ val List(c, o, oMod, t) = compileClassesSeparately(List(codeA, codeB), args + " -opt-warnings", _.msg contains warn)
assertInvoke(getMethod(c, "t1"), "T", "f")
assertNoInvoke(getMethod(c, "t2"))
assertNoInvoke(getMethod(c, "t3"))
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
index fb708c4f29..333792677a 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -19,9 +19,9 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class InlinerTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:classpath -Yopt-warnings"
+ override def compilerArgs = "-opt:l:classpath -opt-warnings"
- val inlineOnlyCompiler = cached("inlineOnlyCompiler", () => newCompiler(extraArgs = "-Yopt:inline-project"))
+ val inlineOnlyCompiler = cached("inlineOnlyCompiler", () => newCompiler(extraArgs = "-opt:inline-project"))
import compiler._
import global.genBCode.bTypes
@@ -825,7 +825,7 @@ class InlinerTest extends BytecodeTesting {
var c = 0
- newCompiler(extraArgs = compilerArgs + " -Yopt-warnings:_").compileClasses(
+ newCompiler(extraArgs = compilerArgs + " -opt-warnings:_").compileClasses(
scalaCode,
List((javaCode, "A.java")),
allowMessage = i => {c += 1; i.msg contains warn})
@@ -1459,7 +1459,7 @@ class InlinerTest extends BytecodeTesting {
val codeA = "final class A { @inline def f = 1 }"
val codeB = "class B { def t(a: A) = a.f }"
// tests that no warning is emitted
- val List(a, b) = compileClassesSeparately(List(codeA, codeB), extraArgs = "-Yopt:l:project -Yopt-warnings")
+ val List(a, b) = compileClassesSeparately(List(codeA, codeB), extraArgs = "-opt:l:project -opt-warnings")
assertInvoke(getMethod(b, "t"), "A", "f")
}
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 fa76c0d930..9675e2e445 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
@@ -17,7 +17,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class MethodLevelOptsTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:method"
+ override def compilerArgs = "-opt:l:method"
import compiler._
def wrapInDefault(code: Instruction*) = List(Label(0), LineNumber(1, Label(0))) ::: code.toList ::: List(Label(1))
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala
index 5bd285f97f..4791a29bfb 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala
@@ -14,7 +14,7 @@ import scala.tools.testing.BytecodeTesting
@RunWith(classOf[JUnit4])
class ScalaInlineInfoTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:l:none"
+ override def compilerArgs = "-opt:l:none"
import compiler._
def inlineInfo(c: ClassNode): InlineInfo = c.attrs.asScala.collect({ case a: InlineInfoAttribute => a.inlineInfo }).head
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
index 63bbcc396b..68ce61b48a 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
@@ -17,9 +17,9 @@ import scala.tools.testing.ClearAfterClass
class UnreachableCodeTest extends ClearAfterClass {
// jvm-1.6 enables emitting stack map frames, which impacts the code generation wrt dead basic blocks,
// see comment in BCodeBodyBuilder
- val methodOptCompiler = cached("methodOptCompiler", () => newCompiler(extraArgs = "-Yopt:l:method"))
- val dceCompiler = cached("dceCompiler", () => newCompiler(extraArgs = "-Yopt:unreachable-code"))
- val noOptCompiler = cached("noOptCompiler", () => newCompiler(extraArgs = "-Yopt:l:none"))
+ val methodOptCompiler = cached("methodOptCompiler", () => newCompiler(extraArgs = "-opt:l:method"))
+ val dceCompiler = cached("dceCompiler", () => newCompiler(extraArgs = "-opt:unreachable-code"))
+ val noOptCompiler = cached("noOptCompiler", () => newCompiler(extraArgs = "-opt:l:none"))
def assertEliminateDead(code: (Instruction, Boolean)*): Unit = {
val method = genMethod()(code.map(_._1): _*)
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/UnusedLocalVariablesTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/UnusedLocalVariablesTest.scala
index c9c98b403b..7ca09ff41d 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/UnusedLocalVariablesTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/UnusedLocalVariablesTest.scala
@@ -14,7 +14,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class UnusedLocalVariablesTest extends BytecodeTesting {
- override def compilerArgs = "-Yopt:unreachable-code"
+ override def compilerArgs = "-opt:unreachable-code"
import compiler._
@Test
diff --git a/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala b/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala
index a8dc8eb3e0..01d17110d6 100644
--- a/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala
+++ b/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala
@@ -13,6 +13,14 @@ class ScriptedTest {
// same as by service discovery
//new ScriptEngineManager().getEngineByName("scala").asInstanceOf[ScriptEngine with Compilable]
+ // scripted, but also -Yno-predef -Yno-imports
+ def scriptedNoNothing: ScriptEngine with Compilable = {
+ val settings = new Settings()
+ settings.noimports.value = true
+ settings.nopredef.value = true
+ Scripted(settings = settings)
+ }
+
@Test def eval() = {
val engine = scripted
engine.put("foo","bar")
@@ -24,6 +32,17 @@ class ScriptedTest {
assert("barbar" == c.eval())
assert("bazbaz" == c.eval(bindings))
}
+ @Test def evalNoNothing() = {
+ val engine = scriptedNoNothing
+ engine.put("foo","bar")
+ assert("bar" == engine.eval("foo"))
+ val bindings = engine.createBindings()
+ bindings.put("foo","baz")
+ assert("baz" == engine.eval("foo", bindings))
+ val c = engine.compile("import scala.Predef.augmentString ; def f = foo.asInstanceOf[java.lang.String] ; f * 2")
+ assert("barbar" == c.eval())
+ assert("bazbaz" == c.eval(bindings))
+ }
@Test def `SI-7933 multiple eval compiled script`() = {
val engine = scripted
val init = """val i = new java.util.concurrent.atomic.AtomicInteger"""
diff --git a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
index b6e8d4fbf2..de18dec344 100644
--- a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
+++ b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
@@ -12,7 +12,7 @@ import scala.tools.testing.BytecodeTesting._
@RunWith(classOf[JUnit4])
class PatmatBytecodeTest extends BytecodeTesting {
- val optCompiler = cached("optCompiler", () => newCompiler(extraArgs = "-Yopt:l:project"))
+ val optCompiler = cached("optCompiler", () => newCompiler(extraArgs = "-opt:l:project"))
import compiler._