diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-11-06 17:12:26 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-25 10:36:12 +0100 |
commit | e49fda4fab463da13e084d1deeb6f1a58e0041d1 (patch) | |
tree | c08c32bd384b7d791404a52c2b020f58e4e9f1c5 /test | |
parent | a8d97403928983f72db66c6dab1354e7c89fe343 (diff) | |
download | scala-e49fda4fab463da13e084d1deeb6f1a58e0041d1.tar.gz scala-e49fda4fab463da13e084d1deeb6f1a58e0041d1.tar.bz2 scala-e49fda4fab463da13e084d1deeb6f1a58e0041d1.zip |
Rewrite test for SI-6955
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala | 28 | ||||
-rw-r--r-- | test/pending/run/t6955.scala | 33 |
2 files changed, 28 insertions, 33 deletions
diff --git a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala index 554e8c0150..cccab3a6d7 100644 --- a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala +++ b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala @@ -55,4 +55,32 @@ 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 t6955(): Unit = { + val code = + """class C { + | type Tag = Byte + | + | def s1(i: Tag): Int = i match { // notice type of i is Tag = Byte + | case 1 => 1 + | case 2 => 2 + | case 3 => 3 + | case _ => 0 + | } + | + | // this worked before, should keep working + | def s2(i: Byte): Int = i match { + | case 1 => 1 + | case 2 => 2 + | case 3 => 3 + | case _ => 0 + | } + |} + """.stripMargin + + val List(c) = compileClasses(compiler)(code) + assert(getSingleMethod(c, "s1").instructions.count(_.opcode == TABLESWITCH) == 1, textify(c)) + assert(getSingleMethod(c, "s2").instructions.count(_.opcode == TABLESWITCH) == 1, textify(c)) + } } diff --git a/test/pending/run/t6955.scala b/test/pending/run/t6955.scala deleted file mode 100644 index 787617eff1..0000000000 --- a/test/pending/run/t6955.scala +++ /dev/null @@ -1,33 +0,0 @@ -import scala.tools.partest.IcodeComparison - -// this class should compile to code that uses switches (twice) -class Switches { - type Tag = Byte - - def switchBad(i: Tag): Int = i match { // notice type of i is Tag = Byte - case 1 => 1 - case 2 => 2 - case 3 => 3 - case _ => 0 - } - - // this worked before, should keep working - def switchOkay(i: Byte): Int = i match { - case 1 => 1 - case 2 => 2 - case 3 => 3 - case _ => 0 - } -} - -object Test extends IcodeComparison { - // ensure we get two switches out of this -- ignore the rest of the output for robustness - // exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file) - override def show() = { - val expected = 2 - val actual = (collectIcode() filter { - x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1 - }).size - assert(actual == expected, s"switches expected: $expected, actual: $actual") - } -} |