aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-10-05 18:01:29 +0200
committerGuillaume Martres <smarter@ubuntu.com>2016-10-05 18:02:12 +0200
commite0a14e7939eda6a7f4914831975b2ac8877696f2 (patch)
tree5e93d7743855e8c93697cdf5f460ffa99692aa5c
parent215b97c22bd85fb807896fc03ffaab22c0748414 (diff)
downloaddotty-e0a14e7939eda6a7f4914831975b2ac8877696f2.tar.gz
dotty-e0a14e7939eda6a7f4914831975b2ac8877696f2.tar.bz2
dotty-e0a14e7939eda6a7f4914831975b2ac8877696f2.zip
Add InlineBytecodeTests to check that inline really works
-rw-r--r--test/test/InlineBytecodeTests.scala32
-rw-r--r--tests/pos/inlineUnit.scala7
2 files changed, 32 insertions, 7 deletions
diff --git a/test/test/InlineBytecodeTests.scala b/test/test/InlineBytecodeTests.scala
new file mode 100644
index 000000000..f7dc35305
--- /dev/null
+++ b/test/test/InlineBytecodeTests.scala
@@ -0,0 +1,32 @@
+package test
+
+import org.junit.Assert._
+import org.junit.Test
+
+class InlineBytecodeTests extends DottyBytecodeTest {
+ import ASMConverters._
+ @Test def inlineUnit = {
+ val source = """
+ |class Foo {
+ | inline def foo: Int = 1
+ |
+ | def meth1: Unit = foo
+ | def meth2: Unit = 1
+ |}
+ """.stripMargin
+
+ checkBCode(source) { dir =>
+ val clsIn = dir.lookupName("Foo.class", directory = false).input
+ val clsNode = loadClassNode(clsIn)
+ val meth1 = getMethod(clsNode, "meth1")
+ val meth2 = getMethod(clsNode, "meth2")
+
+ val instructions1 = instructionsFromMethod(meth1)
+ val instructions2 = instructionsFromMethod(meth2)
+
+ assert(instructions1 == instructions2,
+ "`foo` was not properly inlined in `meth1`\n" +
+ diffInstructions(instructions1, instructions2))
+ }
+ }
+}
diff --git a/tests/pos/inlineUnit.scala b/tests/pos/inlineUnit.scala
deleted file mode 100644
index e4f135db7..000000000
--- a/tests/pos/inlineUnit.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-object Test {
- inline def foo: Int = 1
-
- def test: Unit = {
- foo
- }
-}