summaryrefslogtreecommitdiff
path: root/test/files/jvm/bytecode-test-example/Foo_1.scala
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-01-29 16:11:58 -0800
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-01-29 16:11:58 -0800
commit8610d7ec063407f62b11df848dd588e4594b3b40 (patch)
treeecb3af9fbcea35be81f1285be47f2e95d19c46d6 /test/files/jvm/bytecode-test-example/Foo_1.scala
parenteff78b852e8b866badf9b9738f896c2a31c05474 (diff)
downloadscala-8610d7ec063407f62b11df848dd588e4594b3b40.tar.gz
scala-8610d7ec063407f62b11df848dd588e4594b3b40.tar.bz2
scala-8610d7ec063407f62b11df848dd588e4594b3b40.zip
Add Bytecode test (ASM-based) to partest.
This commit introduces a new kind of test `Bytecode` that allows one to inspect bytecode generated for given piece of Scala code. The bytecode inspection is achieved by inspection of ASM trees. See the included example for details. NOTE: This commit does not introduce a new category of pratest tests. Bytecode tests should be run in `jvm` category of partest tests. Specific list of changes: * Add BytecodeTest that contains common utilities to partest * Add asm to classpath when compiling partest. That's not a new dependency as it's being already done for javac task we were running while compiling partest. * Add an example test that shows how to count null checks in given method.
Diffstat (limited to 'test/files/jvm/bytecode-test-example/Foo_1.scala')
-rw-r--r--test/files/jvm/bytecode-test-example/Foo_1.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/files/jvm/bytecode-test-example/Foo_1.scala b/test/files/jvm/bytecode-test-example/Foo_1.scala
new file mode 100644
index 0000000000..4f679d156f
--- /dev/null
+++ b/test/files/jvm/bytecode-test-example/Foo_1.scala
@@ -0,0 +1,9 @@
+class Foo_1 {
+ def foo(x: AnyRef): Int = {
+ val bool = x == null
+ if (x != null)
+ 1
+ else
+ 0
+ }
+}