diff options
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/t7006/Foo_1.flags | 1 | ||||
-rw-r--r-- | test/files/jvm/t7006/Foo_1.scala | 9 | ||||
-rw-r--r-- | test/files/jvm/t7006/Test.scala | 18 |
3 files changed, 28 insertions, 0 deletions
diff --git a/test/files/jvm/t7006/Foo_1.flags b/test/files/jvm/t7006/Foo_1.flags new file mode 100644 index 0000000000..72fe7b1aa0 --- /dev/null +++ b/test/files/jvm/t7006/Foo_1.flags @@ -0,0 +1 @@ + -Ydead-code -Ydebug -Xfatal-warnings diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala new file mode 100644 index 0000000000..f84269daf2 --- /dev/null +++ b/test/files/jvm/t7006/Foo_1.scala @@ -0,0 +1,9 @@ +class Foo_1 { + def foo { + try { + val x = 3 + } finally { + print("hello") + } + } +} diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala new file mode 100644 index 0000000000..5cc38e42a2 --- /dev/null +++ b/test/files/jvm/t7006/Test.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + assert(countNops(methodNode.instructions) == 0) + } + + def countNops(insnList: InsnList): Int = { + def isNop(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == asm.Opcodes.NOP) + insnList.iterator.asScala.count(isNop) + } +} |