diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-05 12:10:30 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-05 12:10:30 -0800 |
commit | 757a3a738cbb373f8f10fdc1f01e9ab6176a7076 (patch) | |
tree | 4ebbc8cd4163c7ec470cec0940d33d0812fd312f /test/files | |
parent | 3d248efcc1925acb7f73b2b2db2184f8d33b68ad (diff) | |
parent | 092345a24c22a821204fb358d33272ae8f7353be (diff) | |
download | scala-757a3a738cbb373f8f10fdc1f01e9ab6176a7076.tar.gz scala-757a3a738cbb373f8f10fdc1f01e9ab6176a7076.tar.bz2 scala-757a3a738cbb373f8f10fdc1f01e9ab6176a7076.zip |
Merge pull request #1568 from retronym/ticket/6611
SI-6611 Tighten up an unsafe array optimization
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..c295368aea --- /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(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) + } +} |