diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-12-11 10:48:40 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-12-13 09:41:51 +0100 |
commit | 60ac9ecdbd9584007d70003bf8e00c4702bbd401 (patch) | |
tree | 935e57edb4de076ee044f4877db7304e08c7c453 /test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala | |
parent | 93de014be97c5f5a707a36ce10eeaab68037fda7 (diff) | |
download | scala-60ac9ecdbd9584007d70003bf8e00c4702bbd401.tar.gz scala-60ac9ecdbd9584007d70003bf8e00c4702bbd401.tar.bz2 scala-60ac9ecdbd9584007d70003bf8e00c4702bbd401.zip |
Make some testing tools from InlinerTest available to other tests
Diffstat (limited to 'test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala')
-rw-r--r-- | test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala index c071745788..69c3f69380 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala @@ -166,6 +166,19 @@ object CodeGenTools { assertTrue(s"\nExpected: $expected\nActual : $actual", actual === expected) } + def assertNoInvoke(m: Method): Unit = assertNoInvoke(m.instructions) + def assertNoInvoke(ins: List[Instruction]): Unit = { + assert(!ins.exists(_.isInstanceOf[Invoke]), ins.stringLines) + } + + def assertInvoke(m: Method, receiver: String, method: String): Unit = assertInvoke(m.instructions, receiver, method) + def assertInvoke(l: List[Instruction], receiver: String, method: String): Unit = { + assert(l.exists { + case Invoke(_, `receiver`, `method`, _, _) => true + case _ => false + }, l.stringLines) + } + def getSingleMethod(classNode: ClassNode, name: String): Method = convertMethod(classNode.methods.asScala.toList.find(_.name == name).get) @@ -195,4 +208,8 @@ object CodeGenTools { implicit class MortalInstruction(val ins: Instruction) extends AnyVal { def dead: (Instruction, Boolean) = (ins, false) } + + implicit class listStringLines[T](val l: List[T]) extends AnyVal { + def stringLines = l.mkString("\n") + } } |