diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test/DottyBytecodeTest.scala | 2 | ||||
-rw-r--r-- | test/test/DottyBytecodeTests.scala | 52 |
2 files changed, 35 insertions, 19 deletions
diff --git a/test/test/DottyBytecodeTest.scala b/test/test/DottyBytecodeTest.scala index 3814b03bd..1acb85cbf 100644 --- a/test/test/DottyBytecodeTest.scala +++ b/test/test/DottyBytecodeTest.scala @@ -107,7 +107,7 @@ trait DottyBytecodeTest extends DottyTest { if (debug || !succ && !shouldFail || succ && shouldFail) instructions.foreach(Console.err.println) - succ + succ && !shouldFail || shouldFail && !succ } def sameBytecode(methA: MethodNode, methB: MethodNode) = { diff --git a/test/test/DottyBytecodeTests.scala b/test/test/DottyBytecodeTests.scala index 6b1562741..5b79772c4 100644 --- a/test/test/DottyBytecodeTests.scala +++ b/test/test/DottyBytecodeTests.scala @@ -46,24 +46,40 @@ class TestBCode extends DottyBytecodeTest { /** This test verifies that simple matches with `@switch` annotations are * indeed transformed to a switch - * - * FIXME: once issue#1258 is resolved, this should be enabled! */ - //@Test def basicTransfromAnnotated = { - // val source = """ - // |object Foo { - // | import scala.annotation.switch - // | def foo(i: Int) = (i: @switch) match { - // | case 2 => println(2) - // | case 1 => println(1) - // | } - // |}""".stripMargin + @Test def basicTransfromAnnotated = { + val source = """ + |object Foo { + | import scala.annotation.switch + | def foo(i: Int) = (i: @switch) match { + | case 2 => println(2) + | case 1 => println(1) + | } + |}""".stripMargin - // checkBCode(source) { dir => - // val moduleIn = dir.lookupName("Foo$.class", directory = false) - // val moduleNode = loadClassNode(moduleIn.input) - // val methodNode = getMethod(moduleNode, "foo") - // assert(verifySwitch(methodNode)) - // } - //} + checkBCode(source) { dir => + val moduleIn = dir.lookupName("Foo$.class", directory = false) + val moduleNode = loadClassNode(moduleIn.input) + val methodNode = getMethod(moduleNode, "foo") + assert(verifySwitch(methodNode)) + } + } + + @Test def failTransform = { + val source = """ + |object Foo { + | import scala.annotation.switch + | def foo(i: Any) = (i: @switch) match { + | case x: String => println("string!") + | case x :: xs => println("list!") + | } + |}""".stripMargin + checkBCode(source) { dir => + val moduleIn = dir.lookupName("Foo$.class", directory = false) + val moduleNode = loadClassNode(moduleIn.input) + val methodNode = getMethod(moduleNode, "foo") + + assert(verifySwitch(methodNode, shouldFail = true)) + } + } } |