From fdf5354eef3d2a75458cf646c00616ca39a4e56b Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 17 May 2016 14:54:53 +0200 Subject: Add switch verification test --- test/test/DottyBytecodeTest.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/test/DottyBytecodeTest.scala') diff --git a/test/test/DottyBytecodeTest.scala b/test/test/DottyBytecodeTest.scala index 6b39116f8..3814b03bd 100644 --- a/test/test/DottyBytecodeTest.scala +++ b/test/test/DottyBytecodeTest.scala @@ -94,6 +94,22 @@ trait DottyBytecodeTest extends DottyTest { } /**************************** Comparison Methods ****************************/ + def verifySwitch(method: MethodNode, shouldFail: Boolean = false, debug: Boolean = false): Boolean = { + val instructions = instructionsFromMethod(method) + + val succ = instructions + .collect { + case x: TableSwitch => x + case x: LookupSwitch => x + } + .length > 0 + + if (debug || !succ && !shouldFail || succ && shouldFail) + instructions.foreach(Console.err.println) + + succ + } + def sameBytecode(methA: MethodNode, methB: MethodNode) = { val isa = instructionsFromMethod(methA) val isb = instructionsFromMethod(methB) -- cgit v1.2.3