diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-24 16:40:51 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-24 16:40:51 -0800 |
commit | 6448f00b175d84f1a4f37ddcca232b32be89ecab (patch) | |
tree | 0910b764b2e1f0d5afcab8700f35572e7ebc8bc8 /test/files | |
parent | bd78be0bed5ad00c3965120311df17f09e656f00 (diff) | |
parent | ba411c4c2cb4b400481ed3dffed30b6975c000c1 (diff) | |
download | scala-6448f00b175d84f1a4f37ddcca232b32be89ecab.tar.gz scala-6448f00b175d84f1a4f37ddcca232b32be89ecab.tar.bz2 scala-6448f00b175d84f1a4f37ddcca232b32be89ecab.zip |
Merge pull request #1953 from retronym/backport/1586
[backport] Fix unsafe array opt. / opt. primitive Array(...)
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/instrumented/t6611.check | 1 | ||||
-rw-r--r-- | test/files/instrumented/t6611.scala | 35 | ||||
-rw-r--r-- | test/files/run/t6611.scala | 61 |
3 files changed, 97 insertions, 0 deletions
diff --git a/test/files/instrumented/t6611.check b/test/files/instrumented/t6611.check new file mode 100644 index 0000000000..5cd691e93a --- /dev/null +++ b/test/files/instrumented/t6611.check @@ -0,0 +1 @@ +Method call statistics: diff --git a/test/files/instrumented/t6611.scala b/test/files/instrumented/t6611.scala new file mode 100644 index 0000000000..4c52f8a5ef --- /dev/null +++ b/test/files/instrumented/t6611.scala @@ -0,0 +1,35 @@ +import scala.tools.partest.instrumented.Instrumentation._ + +object Test { + def main(args: Array[String]) { + startProfiling() + + // tests optimization in Cleanup for varargs reference arrays + Array("") + + + Array(true) + Array(true, false) + Array(1: Byte) + Array(1: Byte, 2: Byte) + Array(1: Short) + Array(1: Short, 2: Short) + Array(1) + Array(1, 2) + Array(1L) + Array(1L, 2L) + Array(1d) + Array(1d, 2d) + Array(1f) + Array(1f, 2f) + + /* Not currently optimized: + Array[Int](1, 2) etc + Array(()) + Array((), ()) + */ + + stopProfiling() + printStatistics() + } +} diff --git a/test/files/run/t6611.scala b/test/files/run/t6611.scala new file mode 100644 index 0000000000..0947a48f90 --- /dev/null +++ b/test/files/run/t6611.scala @@ -0,0 +1,61 @@ +object Test extends App { + locally { + val a = Array("1") + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array("1": Object) + val a2 = Array[Object](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(true) + val a2 = Array[Boolean](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Short) + val a2 = Array[Short](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Byte) + val a2 = Array[Byte](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1) + val a2 = Array[Int](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1L) + val a2 = Array[Long](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1f) + val a2 = Array[Float](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1d) + val a2 = Array[Double](a: _*) + assert(a ne a2) + } + + locally { + val a = Array(()) + val a2 = Array[Unit](a: _*) + assert(a ne a2) + } +} |