Skip to content

Commit e0a14e7

Browse files
committed
Add InlineBytecodeTests to check that inline really works
1 parent 215b97c commit e0a14e7

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

test/test/InlineBytecodeTests.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package test
2+
3+
import org.junit.Assert._
4+
import org.junit.Test
5+
6+
class InlineBytecodeTests extends DottyBytecodeTest {
7+
import ASMConverters._
8+
@Test def inlineUnit = {
9+
val source = """
10+
|class Foo {
11+
| inline def foo: Int = 1
12+
|
13+
| def meth1: Unit = foo
14+
| def meth2: Unit = 1
15+
|}
16+
""".stripMargin
17+
18+
checkBCode(source) { dir =>
19+
val clsIn = dir.lookupName("Foo.class", directory = false).input
20+
val clsNode = loadClassNode(clsIn)
21+
val meth1 = getMethod(clsNode, "meth1")
22+
val meth2 = getMethod(clsNode, "meth2")
23+
24+
val instructions1 = instructionsFromMethod(meth1)
25+
val instructions2 = instructionsFromMethod(meth2)
26+
27+
assert(instructions1 == instructions2,
28+
"`foo` was not properly inlined in `meth1`\n" +
29+
diffInstructions(instructions1, instructions2))
30+
}
31+
}
32+
}

tests/pos/inlineUnit.scala

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)