summaryrefslogtreecommitdiff
path: root/test/files/jvm/t6941
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-01-31 10:18:26 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-01-31 11:00:44 -0800
commitb2117cf6f4080eff9028b2aa33a013329022efd6 (patch)
tree0cdfb6a34583a4b0ae41ca086256cf67acca25fb /test/files/jvm/t6941
parentb92396b57912f040d8f536b8a60b844ff586ff0d (diff)
downloadscala-b2117cf6f4080eff9028b2aa33a013329022efd6.tar.gz
scala-b2117cf6f4080eff9028b2aa33a013329022efd6.tar.bz2
scala-b2117cf6f4080eff9028b2aa33a013329022efd6.zip
SI-6941 tests
tests that the methods' bytecodes are similar as variable load/stores are reordered, it ignores which variables are modified when checking for bytecode equality the assert is: `similarBytecode(methNodeA, methNodeB, equalsModuloVar)`
Diffstat (limited to 'test/files/jvm/t6941')
-rw-r--r--test/files/jvm/t6941/Analyzed_1.scala11
-rw-r--r--test/files/jvm/t6941/test.scala15
2 files changed, 26 insertions, 0 deletions
diff --git a/test/files/jvm/t6941/Analyzed_1.scala b/test/files/jvm/t6941/Analyzed_1.scala
new file mode 100644
index 0000000000..549abd5e64
--- /dev/null
+++ b/test/files/jvm/t6941/Analyzed_1.scala
@@ -0,0 +1,11 @@
+// this class's bytecode, compiled under -optimize is analyzed by the test
+// method a's bytecode should be identical to method b's bytecode
+class SameBytecode {
+ def a(xs: List[Int]) = xs match {
+ case x :: _ => x
+ }
+
+ def b(xs: List[Int]) = xs match {
+ case xs: ::[Int] => xs.hd$1
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/t6941/test.scala b/test/files/jvm/t6941/test.scala
new file mode 100644
index 0000000000..248617f71f
--- /dev/null
+++ b/test/files/jvm/t6941/test.scala
@@ -0,0 +1,15 @@
+import scala.tools.partest.BytecodeTest
+
+import scala.tools.nsc.util.JavaClassPath
+import java.io.InputStream
+import scala.tools.asm
+import asm.ClassReader
+import asm.tree.{ClassNode, InsnList}
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("SameBytecode")
+ similarBytecode(getMethod(classNode, "a"), getMethod(classNode, "b"), equalsModuloVar)
+ }
+}