diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-11-09 12:44:07 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-25 11:39:30 +0100 |
commit | f4a74f7eefb0521c0531f930ac8fd505953e0f50 (patch) | |
tree | bc2d5950c3dce5757ac93db163715a33064656c7 /test | |
parent | 454af8cfedb3a126ffc4de4fe01e0b3ebe538a77 (diff) | |
download | scala-f4a74f7eefb0521c0531f930ac8fd505953e0f50.tar.gz scala-f4a74f7eefb0521c0531f930ac8fd505953e0f50.tar.bz2 scala-f4a74f7eefb0521c0531f930ac8fd505953e0f50.zip |
Rewrite test: no null in patmat
Diffstat (limited to 'test')
5 files changed, 13 insertions, 40 deletions
diff --git a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala index b53f7693dc..5aac1f4656 100644 --- a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala +++ b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala @@ -102,4 +102,17 @@ class PatmatBytecodeTest extends ClearAfterClass { "y", ARETURN)) } + @Test + def optNoNullCheck(): Unit = { + val code = + """case class Foo(x: Any) + |class C { + | def a = (Foo(1): Any) match { + | case Foo(_: String) => + | } + |} + """.stripMargin + val c = compileClasses(optCompiler)(code).head + assert(!getSingleMethod(c, "a").instructions.exists(i => i.opcode == IFNULL || i.opcode == IFNONNULL), textify(findAsmMethod(c, "a"))) + } } diff --git a/test/pending/jvm/patmat_opt_no_nullcheck.check b/test/pending/jvm/patmat_opt_no_nullcheck.check deleted file mode 100644 index 43f53aba12..0000000000 --- a/test/pending/jvm/patmat_opt_no_nullcheck.check +++ /dev/null @@ -1 +0,0 @@ -bytecode identical diff --git a/test/pending/jvm/patmat_opt_no_nullcheck.flags b/test/pending/jvm/patmat_opt_no_nullcheck.flags deleted file mode 100644 index 453b6b7895..0000000000 --- a/test/pending/jvm/patmat_opt_no_nullcheck.flags +++ /dev/null @@ -1 +0,0 @@ --Yopt:l:project
\ No newline at end of file diff --git a/test/pending/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala b/test/pending/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala deleted file mode 100644 index 1e4d564cdf..0000000000 --- a/test/pending/jvm/patmat_opt_no_nullcheck/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 -case class Foo(x: Any) - -class SameBytecode { - def a = - (Foo(1): Any) match { - case Foo(_: String) => - } - - // there's no null check - def b: Unit = { - val x1: Any = Foo(1) - if (x1.isInstanceOf[Foo]) { - val x3 = x1.asInstanceOf[Foo] - if (x3.x.isInstanceOf[String]) { - val x = () - return - } - } - - throw new MatchError(x1) - } -}
\ No newline at end of file diff --git a/test/pending/jvm/patmat_opt_no_nullcheck/test.scala b/test/pending/jvm/patmat_opt_no_nullcheck/test.scala deleted file mode 100644 index 5a4a398b67..0000000000 --- a/test/pending/jvm/patmat_opt_no_nullcheck/test.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* - * filter: inliner warning; re-run with - */ -import scala.tools.partest.{ BytecodeTest, ASMConverters } - -object Test extends BytecodeTest { - def show: Unit = { - val classNode = loadClassNode("SameBytecode") - // ASM and GenBCode assign variable slots slightly differently - val instrsA = ASMConverters.instructionsFromMethod(getMethod(classNode, "a")) - val instrsB = ASMConverters.instructionsFromMethod(getMethod(classNode, "b")) - assert(ASMConverters.equivalentBytecode(instrsA, instrsB), diffInstructions(instrsA, instrsB)) // doesn't work - } -} |