diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-05-17 14:54:53 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-05-17 14:54:53 +0200 |
commit | fdf5354eef3d2a75458cf646c00616ca39a4e56b (patch) | |
tree | 467c565f4c2dd4d63559e3c898a384afc6a02936 /test/test/DottyBytecodeTest.scala | |
parent | eaf2520b63fcc9fe65cf02d88c96849c4caf8177 (diff) | |
download | dotty-fdf5354eef3d2a75458cf646c00616ca39a4e56b.tar.gz dotty-fdf5354eef3d2a75458cf646c00616ca39a4e56b.tar.bz2 dotty-fdf5354eef3d2a75458cf646c00616ca39a4e56b.zip |
Add switch verification test
Diffstat (limited to 'test/test/DottyBytecodeTest.scala')
-rw-r--r-- | test/test/DottyBytecodeTest.scala | 16 |
1 files changed, 16 insertions, 0 deletions
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) |