diff options
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/t7006/Foo_1.scala | 3 | ||||
-rw-r--r-- | test/files/jvm/t7006/Test.scala | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala index f84269daf2..995619ce6b 100644 --- a/test/files/jvm/t7006/Foo_1.scala +++ b/test/files/jvm/t7006/Foo_1.scala @@ -1,9 +1,10 @@ class Foo_1 { def foo { try { - val x = 3 + val x = 3 // this will be optimized away, leaving a useless jump only block } finally { print("hello") } + while(true){} // ensure infinite loop doesn't break the algoirthm } } diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala index 5cc38e42a2..065a23510e 100644 --- a/test/files/jvm/t7006/Test.scala +++ b/test/files/jvm/t7006/Test.scala @@ -7,12 +7,13 @@ object Test extends BytecodeTest { def show: Unit = { val classNode = loadClassNode("Foo_1") val methodNode = getMethod(classNode, "foo") - assert(countNops(methodNode.instructions) == 0) + assert(count(methodNode.instructions, asm.Opcodes.NOP) == 0) + assert(count(methodNode.instructions, asm.Opcodes.GOTO) == 1) } - def countNops(insnList: InsnList): Int = { + def count(insnList: InsnList, opcode: Int): Int = { def isNop(node: asm.tree.AbstractInsnNode): Boolean = - (node.getOpcode == asm.Opcodes.NOP) + (node.getOpcode == opcode) insnList.iterator.asScala.count(isNop) } } |