Skip to content
Browse files

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)`
  • Loading branch information...
1 parent b92396b commit b2117cf6f4080eff9028b2aa33a013329022efd6 @adriaanm adriaanm committed Jan 31, 2013
View
1 test/files/jvm/t6941.check
@@ -0,0 +1 @@
+bytecode identical
View
1 test/files/jvm/t6941.flags
@@ -0,0 +1 @@
+-optimize
View
11 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
+ }
+}
View
15 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)
+ }
+}

2 comments on commit b2117cf

@scala-jenkins

Job pr-checkin-per-commit failed for b2117cf (results):


Took 4 min.
sad kitty
to rebuild, comment "PLS REBUILD/pr-checkin-per-commit@b2117cf"on PR #2112

@scala-jenkins

Job pr-rangepos-per-commit failed for b2117cf (results):


Took 4 min.
sad kitty
to rebuild, comment "PLS REBUILD/pr-rangepos-per-commit@b2117cf"on PR #2112

Please sign in to comment.
Something went wrong with that request. Please try again.