diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-17 15:18:06 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-17 15:18:06 +0000 |
commit | 16e7ad360d1a902d6bd5c845642dbe14bcecdb9d (patch) | |
tree | a189e624a75dbb47a689a821208b41b0141e2ee0 /test/files/specialized/spec-patmatch.scala | |
parent | be2778d50f1a73a941c6ffe6355f0ed401d6d8eb (diff) | |
download | scala-16e7ad360d1a902d6bd5c845642dbe14bcecdb9d.tar.gz scala-16e7ad360d1a902d6bd5c845642dbe14bcecdb9d.tar.bz2 scala-16e7ad360d1a902d6bd5c845642dbe14bcecdb9d.zip |
Adapted specialization tests to track number of...
Adapted specialization tests to track number of boxings.
Review by dragos
Diffstat (limited to 'test/files/specialized/spec-patmatch.scala')
-rw-r--r-- | test/files/specialized/spec-patmatch.scala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/files/specialized/spec-patmatch.scala b/test/files/specialized/spec-patmatch.scala new file mode 100644 index 0000000000..909629455d --- /dev/null +++ b/test/files/specialized/spec-patmatch.scala @@ -0,0 +1,53 @@ +class Foo[@specialized A] { + def test(x: A) = println(x match { + case _: Boolean => "bool" + case _: Byte => "byte" + case _: Short => "short" + case _: Char => "char" + case i: Int => "int" + case l: Long => "long" + case d: Double => "double" + case e: Float => "float" + case _ => "default" + }) +} + +object Test { + def test[@specialized A] (x: A) = println(x match { + case _: Boolean => "bool" + case _: Byte => "byte" + case _: Short => "short" + case _: Char => "char" + case i: Int => "int" + case l: Long => "long" + case d: Double => "double" + case e: Float => "float" + case _ => "default" + }) + + def main(args: Array[String]) { + test(true) + test(42.toByte) + test(42.toShort) + test('b') + test(42) + test(42l) + test(42.0) + test(42.0f) + test(new Object) + + println("object instantiations:") + (new Foo).test(true) + (new Foo).test(42.toByte) + (new Foo).test(42.toShort) + (new Foo).test('b') + (new Foo).test(42) + (new Foo).test(42l) + (new Foo).test(42.0) + (new Foo).test(42.0f) + (new Foo).test(new Object) + + println(runtime.BoxesRunTime.integerBoxCount) + } + +} |