Skip to content

Commit

Permalink
SI-6941 tests
Browse files Browse the repository at this point in the history
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
adriaanm committed Jan 31, 2013
1 parent b92396b commit b2117cf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/files/jvm/t6941.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bytecode identical
1 change: 1 addition & 0 deletions test/files/jvm/t6941.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-optimize
11 changes: 11 additions & 0 deletions test/files/jvm/t6941/Analyzed_1.scala
Original file line number Diff line number Diff line change
@@ -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
}
}
15 changes: 15 additions & 0 deletions test/files/jvm/t6941/test.scala
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


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

@scala-jenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


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

Please sign in to comment.