diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-04 14:17:25 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-04 14:17:25 +0100 |
commit | 8265175ecc42293997d59049f430396c77a2b891 (patch) | |
tree | a24c7820bee892eb802d5c691e1e57a62ff43bb4 /test/files | |
parent | dad886659faca4fba2d4937c9bc6780591b02c27 (diff) | |
download | scala-8265175ecc42293997d59049f430396c77a2b891.tar.gz scala-8265175ecc42293997d59049f430396c77a2b891.tar.bz2 scala-8265175ecc42293997d59049f430396c77a2b891.zip |
Expand optimization of Array(e1, ..., en) to primitive arrays.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/instrumented/t6611.scala | 24 | ||||
-rw-r--r-- | test/files/run/t6611.scala | 63 |
2 files changed, 82 insertions, 5 deletions
diff --git a/test/files/instrumented/t6611.scala b/test/files/instrumented/t6611.scala index 821d5f3fbf..4c52f8a5ef 100644 --- a/test/files/instrumented/t6611.scala +++ b/test/files/instrumented/t6611.scala @@ -5,7 +5,29 @@ object Test { startProfiling() // tests optimization in Cleanup for varargs reference arrays - val a = Array("") + 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 index c0297372f0..c295368aea 100644 --- a/test/files/run/t6611.scala +++ b/test/files/run/t6611.scala @@ -1,6 +1,61 @@ object Test extends App { - val a = Array("1") - val a2 = Array(a: _*) - a2(0) = "2" - assert(a(0) == "1") + locally { + val a = Array("1") + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array("1": Object) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(true) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Short) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1: Byte) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1L) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1f) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(1d) + val a2 = Array(a: _*) + assert(a ne a2) + } + + locally { + val a = Array(()) + val a2 = Array(a: _*) + assert(a ne a2) + } } |