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/run | |
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/run')
-rw-r--r-- | test/files/run/spec-absfun.scala | 43 | ||||
-rw-r--r-- | test/files/run/spec-ame.check | 2 | ||||
-rw-r--r-- | test/files/run/spec-ame.scala | 17 | ||||
-rw-r--r-- | test/files/run/spec-constr.check | 2 | ||||
-rw-r--r-- | test/files/run/spec-constr.scala | 14 | ||||
-rw-r--r-- | test/files/run/spec-early.check | 4 | ||||
-rw-r--r-- | test/files/run/spec-early.scala | 15 | ||||
-rw-r--r-- | test/files/run/spec-init.check | 9 | ||||
-rw-r--r-- | test/files/run/spec-init.scala | 40 | ||||
-rw-r--r-- | test/files/run/spec-matrix.check | 1 | ||||
-rw-r--r-- | test/files/run/spec-matrix.scala | 70 | ||||
-rw-r--r-- | test/files/run/spec-overrides.check | 0 | ||||
-rw-r--r-- | test/files/run/spec-overrides.scala | 20 | ||||
-rw-r--r-- | test/files/run/spec-patmatch.check | 19 | ||||
-rw-r--r-- | test/files/run/spec-patmatch.scala | 52 | ||||
-rw-r--r-- | test/files/run/spec-super.check | 2 | ||||
-rw-r--r-- | test/files/run/spec-super.scala | 18 | ||||
-rw-r--r-- | test/files/run/spec-t3896.check | 2 | ||||
-rw-r--r-- | test/files/run/spec-t3896.scala | 18 |
19 files changed, 0 insertions, 348 deletions
diff --git a/test/files/run/spec-absfun.scala b/test/files/run/spec-absfun.scala deleted file mode 100644 index 2b780548f5..0000000000 --- a/test/files/run/spec-absfun.scala +++ /dev/null @@ -1,43 +0,0 @@ - -/** Test inheritance. See #3085. - * Anonymous functions extend AbstractFunction1[SpecializedPair[Int], Unit]. The - * specialized type SpecializedPair$mcI$sp should not leak into the superclass because - * the definition of apply would vary covariantly, and erasure won't consider it an - * override of the abstract apply, leading to an AbstractMethodError at runtime. - */ - -object Test { - - private val Max = 1000 - - def main(args: Array[String]) { - notSpecialized() - specialized() - } - - def notSpecialized() { - val pairs = for { i <- 1 to Max; j <- 1 to i } yield new Pair(i, j) - val time0 = System.nanoTime - pairs foreach { p => p.first * p.second } - val time1 = System.nanoTime -// println(time1 - time0) - } - - def specialized() { - val pairs = for { i <- 1 to Max; j <- 1 to i } yield new SpecializedPair(i, j) - val time0 = System.nanoTime - pairs foreach { p => p.first * p.second } - val time1 = System.nanoTime -// println(time1 - time0) - } -} - -class Pair[A](_first: A, _second: A) { - def first = _first - def second = _second -} - -class SpecializedPair[@specialized(Int) A](_first: A, _second: A) { - def first = _first - def second = _second -} diff --git a/test/files/run/spec-ame.check b/test/files/run/spec-ame.check deleted file mode 100644 index afa12db4df..0000000000 --- a/test/files/run/spec-ame.check +++ /dev/null @@ -1,2 +0,0 @@ -abc -10 diff --git a/test/files/run/spec-ame.scala b/test/files/run/spec-ame.scala deleted file mode 100644 index 86c47077f0..0000000000 --- a/test/files/run/spec-ame.scala +++ /dev/null @@ -1,17 +0,0 @@ -// ticket #3432 -object Test { - trait B[@specialized(Int) T] { - def value: T - } - - class A[@specialized(Int) T](x: T) { - def foo: B[T] = new B[T] { - def value = x - } - } - - def main(args: Array[String]) { - println((new A("abc")).foo.value) - println((new A(10)).foo.value) - } -} diff --git a/test/files/run/spec-constr.check b/test/files/run/spec-constr.check deleted file mode 100644 index 29d70d9de8..0000000000 --- a/test/files/run/spec-constr.check +++ /dev/null @@ -1,2 +0,0 @@ -hello? -goodbye diff --git a/test/files/run/spec-constr.scala b/test/files/run/spec-constr.scala deleted file mode 100644 index 4c80d0954d..0000000000 --- a/test/files/run/spec-constr.scala +++ /dev/null @@ -1,14 +0,0 @@ -object Test { - class E[@specialized(Int) A](var f: A => Boolean) { - def this() = this(null) - - println("hello?") - if (f == null) f = { _ => false } - } - - def main(args: Array[String]) { - new E[Int] - println("goodbye") - } -} - diff --git a/test/files/run/spec-early.check b/test/files/run/spec-early.check deleted file mode 100644 index 414aacc419..0000000000 --- a/test/files/run/spec-early.check +++ /dev/null @@ -1,4 +0,0 @@ -a -abc -42 -abc diff --git a/test/files/run/spec-early.scala b/test/files/run/spec-early.scala deleted file mode 100644 index 84a8983f8c..0000000000 --- a/test/files/run/spec-early.scala +++ /dev/null @@ -1,15 +0,0 @@ -trait Tr - -class Foo[@specialized(Int) T](_x: T) extends { - val bar = "abc" - val baz = "bbc" -} with Tr { - val x = _x - println(x) - println(bar) -} - -object Test extends Application { - new Foo("a") - new Foo(42) -} diff --git a/test/files/run/spec-init.check b/test/files/run/spec-init.check deleted file mode 100644 index 7705ee2947..0000000000 --- a/test/files/run/spec-init.check +++ /dev/null @@ -1,9 +0,0 @@ -abc -abc -abc -shouldn't see two initialized values and one uninitialized -42 -42 -42 -ok -ok diff --git a/test/files/run/spec-init.scala b/test/files/run/spec-init.scala deleted file mode 100644 index 60852245b4..0000000000 --- a/test/files/run/spec-init.scala +++ /dev/null @@ -1,40 +0,0 @@ -class Foo[@specialized(Int) T](_x: T) { - val x = _x - def bar {} - - val y = x - println(x) - println(y) - - def baz {} - val z = y - println(z) -} - -class Bar[@specialized(Int) T] { - def foo(x: T) = print(x) -} - -object Global { - var msg = "ok" -} - -class TouchGlobal[@specialized(Int) T](_x: T) { - println(Global.msg) - val x = { - Global.msg = "not ok" - _x - } -} - -object Test { - def main(args: Array[String]) { - (new Foo("abc")) - println("shouldn't see two initialized values and one uninitialized") - (new Foo(42)) - - (new TouchGlobal(new Object)) - Global.msg = "ok" // reset the value - (new TouchGlobal(42)) - } -} diff --git a/test/files/run/spec-matrix.check b/test/files/run/spec-matrix.check deleted file mode 100644 index 72e8ffc0db..0000000000 --- a/test/files/run/spec-matrix.check +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/test/files/run/spec-matrix.scala b/test/files/run/spec-matrix.scala deleted file mode 100644 index 81e3eaf212..0000000000 --- a/test/files/run/spec-matrix.scala +++ /dev/null @@ -1,70 +0,0 @@ -/** Test matrix multiplication with specialization. - */ - -class Matrix[@specialized A: ClassManifest](val rows: Int, val cols: Int) { - private val arr: Array[Array[A]] = new Array[Array[A]](rows, cols) - - def apply(i: Int, j: Int): A = { - if (i < 0 || i >= rows || j < 0 || j >= cols) - throw new NoSuchElementException("Indexes out of bounds: " + (i, j)) - - arr(i)(j) - } - - def update(i: Int, j: Int, e: A) { - arr(i)(j) = e - } - - def rowsIterator: Iterator[Array[A]] = new Iterator[Array[A]] { - var idx = 0; - def hasNext = idx < rows - def next = { - idx += 1 - arr(idx - 1) - } - } -} - -object Test { - def main(args: Array[String]) { - val m = randomMatrix(200, 100) - val n = randomMatrix(100, 200) - - mult(m, n) - println("*") - } - - def randomMatrix(n: Int, m: Int) = { - val r = new util.Random(10) - val x = new Matrix[Int](n, m) - for (i <- 0 until n; j <- 0 until m) - x(i, j) = r.nextInt - x - } - - - def multManifest[@specialized(Int) T](m: Matrix[T], n: Matrix[T])(implicit cm: ClassManifest[T], num: Numeric[T]) { - val p = new Matrix[T](m.rows, n.cols) - import num._ - - for (i <- 0 until m.rows) - for (j <- 0 until n.cols) { - var sum = num.zero - for (k <- 0 until n.rows) - sum += m(i, k) * n(k, j) - p(i, j) = sum - } - } - - def mult(m: Matrix[Int], n: Matrix[Int]) { - val p = new Matrix[Int](m.rows, n.cols) - - for (i <- 0 until m.rows) - for (j <- 0 until n.cols) { - var sum = 0 - for (k <- 0 until n.rows) - sum += m(i, k) * n(k, j) - p(i, j) = sum - } - } -} diff --git a/test/files/run/spec-overrides.check b/test/files/run/spec-overrides.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/spec-overrides.check +++ /dev/null diff --git a/test/files/run/spec-overrides.scala b/test/files/run/spec-overrides.scala deleted file mode 100644 index f5d2e2f9c7..0000000000 --- a/test/files/run/spec-overrides.scala +++ /dev/null @@ -1,20 +0,0 @@ - trait Base[@specialized(Double) B] { - def default: B; - } - - trait D1 extends Base[Double] { - override def default = 0.0; - } - - class D2 extends D1 { - override def default: Double = 1.0; - } - - -object Test extends Application { - val d2 = new D2 - - assert(d2.default == 1.0, d2.default) - assert((d2: Base[_]).default == 1.0, (d2: Base[_]).default) - assert((d2: D1).default == 1.0, (d2: D1).default) -} diff --git a/test/files/run/spec-patmatch.check b/test/files/run/spec-patmatch.check deleted file mode 100644 index a6679fa1c7..0000000000 --- a/test/files/run/spec-patmatch.check +++ /dev/null @@ -1,19 +0,0 @@ -bool -byte -short -char -int -long -double -float -default -object instantiations: -bool -byte -short -char -int -long -double -float -default diff --git a/test/files/run/spec-patmatch.scala b/test/files/run/spec-patmatch.scala deleted file mode 100644 index 92938836d8..0000000000 --- a/test/files/run/spec-patmatch.scala +++ /dev/null @@ -1,52 +0,0 @@ -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) - - } - -} diff --git a/test/files/run/spec-super.check b/test/files/run/spec-super.check deleted file mode 100644 index c04dfc9fdf..0000000000 --- a/test/files/run/spec-super.check +++ /dev/null @@ -1,2 +0,0 @@ -s -1 diff --git a/test/files/run/spec-super.scala b/test/files/run/spec-super.scala deleted file mode 100644 index ae71d72859..0000000000 --- a/test/files/run/spec-super.scala +++ /dev/null @@ -1,18 +0,0 @@ - -// see ticket #3651 -object Test { - def main(args: Array[String]) { - val s = new Extended("s") - println(s.foo) //works - - val i = new Extended(1) - println(i.foo) //infinite loop with StackOverflowError - } -} - -class Base[@specialized(Int) T](val t: T) { - def foo() :T = t -} -class Extended [@specialized(Int) T](t: T) extends Base[T](t) { - override def foo() :T = super.foo -} diff --git a/test/files/run/spec-t3896.check b/test/files/run/spec-t3896.check deleted file mode 100644 index bb101b641b..0000000000 --- a/test/files/run/spec-t3896.check +++ /dev/null @@ -1,2 +0,0 @@ -true -true diff --git a/test/files/run/spec-t3896.scala b/test/files/run/spec-t3896.scala deleted file mode 100644 index 4c4dadbe13..0000000000 --- a/test/files/run/spec-t3896.scala +++ /dev/null @@ -1,18 +0,0 @@ -// see ticket #3896. Tests interaction between overloading, specialization and default params -trait Atomic[@specialized(Boolean) T] { - def x: T - - // crash depends on the overloading: if second method is "g", no crash. - def f(fn: T => T): Boolean = f(fn(x)) - def f[R](a: T, b: R = true) = b -} -class AtomicBoolean(val x: Boolean) extends Atomic[Boolean] - -object Test { - def main(args: Array[String]): Unit = { - val e = new AtomicBoolean(false) - val x = e.f( (a : Boolean) => !a ) // ok - println( e.f( (a : Boolean) => !a ) toString ) // ok - println( e.f( (a : Boolean) => !a) ) // compiler crash - } -} |