summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-11-09 12:33:16 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-01-25 11:39:16 +0100
commit454af8cfedb3a126ffc4de4fe01e0b3ebe538a77 (patch)
tree3565105b152c93d749156aa65907c98fd773d333
parent0210d265f900941a0c17bb73f8de4c784ab27fc0 (diff)
downloadscala-454af8cfedb3a126ffc4de4fe01e0b3ebe538a77.tar.gz
scala-454af8cfedb3a126ffc4de4fe01e0b3ebe538a77.tar.bz2
scala-454af8cfedb3a126ffc4de4fe01e0b3ebe538a77.zip
Rewrite test: no type test on primitives in patmat
-rw-r--r--test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala19
-rw-r--r--test/pending/jvm/patmat_opt_primitive_typetest.check1
-rw-r--r--test/pending/jvm/patmat_opt_primitive_typetest.flags1
-rw-r--r--test/pending/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala24
-rw-r--r--test/pending/jvm/patmat_opt_primitive_typetest/test.scala8
5 files changed, 19 insertions, 34 deletions
diff --git a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
index cccab3a6d7..b53f7693dc 100644
--- a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
+++ b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
@@ -83,4 +83,23 @@ class PatmatBytecodeTest extends ClearAfterClass {
assert(getSingleMethod(c, "s1").instructions.count(_.opcode == TABLESWITCH) == 1, textify(c))
assert(getSingleMethod(c, "s2").instructions.count(_.opcode == TABLESWITCH) == 1, textify(c))
}
+
+ @Test
+ def optNoPrimitiveTypetest(): Unit = {
+ val code =
+ """case class Foo(x: Int, y: String)
+ |class C {
+ | def a = Foo(1, "a") match {
+ | case Foo(_: Int, y) => y
+ | }
+ |}
+ """.stripMargin
+ val c = compileClasses(optCompiler)(code).head
+
+ assertEquals(textify(findAsmMethod(c, "a")), getSingleMethod(c, "a").instructions.summary,
+ List(
+ NEW, DUP, ICONST_1, LDC, "<init>",
+ "y", ARETURN))
+ }
+
}
diff --git a/test/pending/jvm/patmat_opt_primitive_typetest.check b/test/pending/jvm/patmat_opt_primitive_typetest.check
deleted file mode 100644
index 43f53aba12..0000000000
--- a/test/pending/jvm/patmat_opt_primitive_typetest.check
+++ /dev/null
@@ -1 +0,0 @@
-bytecode identical
diff --git a/test/pending/jvm/patmat_opt_primitive_typetest.flags b/test/pending/jvm/patmat_opt_primitive_typetest.flags
deleted file mode 100644
index 19c578e4ad..0000000000
--- a/test/pending/jvm/patmat_opt_primitive_typetest.flags
+++ /dev/null
@@ -1 +0,0 @@
--Yopt:l:project
diff --git a/test/pending/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala b/test/pending/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala
deleted file mode 100644
index c961082fa7..0000000000
--- a/test/pending/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-// this class's bytecode, compiled under -optimize is analyzed by the test
-// method a's bytecode should be identical to method b's bytecode
-class SameBytecode {
- case class Foo(x: Int, y: String)
-
- def a =
- Foo(1, "a") match {
- case Foo(_: Int, y) => y
- }
-
- // this method's body holds the tree that should be generated by the pattern matcher for method a (-Xprint:patmat)
- // the test checks that bytecode for a and b is identical (modulo line numbers)
- // we can't diff trees as they are quite different (patmat uses jumps to labels that cannot be expressed in source, for example)
- // note that the actual tree is quite bad: we do an unnecessary null check, and local val (x3)
- // some of these will be fixed soon (the initial null check is for the scrutinee, which is harder to fix in patmat)
- def b: String = {
- val x1 = Foo(1, "a")
- if (x1.ne(null)) {
- return x1.y
- }
-
- throw new MatchError(x1)
- }
-} \ No newline at end of file
diff --git a/test/pending/jvm/patmat_opt_primitive_typetest/test.scala b/test/pending/jvm/patmat_opt_primitive_typetest/test.scala
deleted file mode 100644
index 2927e763d5..0000000000
--- a/test/pending/jvm/patmat_opt_primitive_typetest/test.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.tools.partest.BytecodeTest
-
-object Test extends BytecodeTest {
- def show: Unit = {
- val classNode = loadClassNode("SameBytecode")
- sameBytecode(getMethod(classNode, "a"), getMethod(classNode, "b"))
- }
-}