From e0a14e7939eda6a7f4914831975b2ac8877696f2 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 5 Oct 2016 18:01:29 +0200 Subject: Add InlineBytecodeTests to check that inline really works --- test/test/InlineBytecodeTests.scala | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/test/InlineBytecodeTests.scala (limited to 'test/test/InlineBytecodeTests.scala') 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)) + } + } +} -- cgit v1.2.3