summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-11-09 09:45:11 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-01-25 11:34:30 +0100
commit062109b51d0dba640933d749bf07f55d84f450d4 (patch)
treec7b00d187f49b777239f6ac1f3b8632e2e61c8b3 /test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
parent9f7446450fec15d7563e5dcd0c12f56350951b7d (diff)
downloadscala-062109b51d0dba640933d749bf07f55d84f450d4.tar.gz
scala-062109b51d0dba640933d749bf07f55d84f450d4.tar.bz2
scala-062109b51d0dba640933d749bf07f55d84f450d4.zip
Rewrite test for inlining higher-order functions
Diffstat (limited to 'test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala')
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
index 77133255f4..942b62b32c 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -1496,4 +1496,24 @@ class InlinerTest extends ClearAfterClass {
IFNONNULL, ACONST_NULL, ATHROW, -1 /*label*/,
ILOAD, ICONST_1, IADD, IRETURN))
}
+
+ @Test // a test taken from the test suite for the 2.11 inliner
+ def oldInlineHigherOrderTest(): Unit = {
+ val code =
+ """class C {
+ | private var debug = false
+ | @inline private def ifelse[T](cond: => Boolean, ifPart: => T, elsePart: => T): T = if (cond) ifPart else elsePart
+ | final def t = ifelse(debug, 1, 2)
+ |}
+ """.stripMargin
+ val List(c) = compile(code)
+ val t = getSingleMethod(c, "t")
+
+ // box-unbox will clean it up
+ assertEquals(getSingleMethod(c, "t").instructions.summary,
+ List(
+ ALOAD, "C$$$anonfun$1", IFEQ /*A*/,
+ "C$$$anonfun$2", IRETURN,
+ -1 /*A*/, "C$$$anonfun$3", IRETURN))
+ }
}