summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-09 15:46:50 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-09 15:46:50 +0000
commitd34d0d5108542f6eb9ec46acb5daadd5ad4fb7ef (patch)
tree36d3d144fcd65146d0502c048780a993257d38a0 /test/files
parentd5fbd26715a9084595b605a6b2bfd24cd6f2b66e (diff)
downloadscala-d34d0d5108542f6eb9ec46acb5daadd5ad4fb7ef.tar.gz
scala-d34d0d5108542f6eb9ec46acb5daadd5ad4fb7ef.tar.bz2
scala-d34d0d5108542f6eb9ec46acb5daadd5ad4fb7ef.zip
Added a test case for anyref specialization.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/pos/spec.scala64
-rw-r--r--test/files/specialized/arrays.check4
-rw-r--r--test/files/specialized/arrays.scala55
-rw-r--r--test/files/speclib/instrumented.jar.desired.sha12
4 files changed, 124 insertions, 1 deletions
diff --git a/test/files/pos/spec.scala b/test/files/pos/spec.scala
new file mode 100644
index 0000000000..e8df1bb14a
--- /dev/null
+++ b/test/files/pos/spec.scala
@@ -0,0 +1,64 @@
+
+
+
+
+// class Bar[@specialized(Int, AnyRef) A](a: A) {
+// val memb = a
+// }
+
+
+// class WithInner[@specialized(Int, AnyRef) A](a: A) {
+// class Inner {
+// def meth = a
+// }
+// }
+
+
+// class Baz[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B] {
+// def ab(a: A, b: B) = (a, b)
+// }
+
+
+// trait Base[@specialized(Int, AnyRef) A]
+// class Concrete[@specialized(Int, AnyRef) A] extends Base[A]
+
+
+// class WithAnon[@specialized(Int, AnyRef) A](a: A) {
+// new AnyRef {
+// def foo = a
+// }
+// }
+
+
+// class Norm {
+// def id[@specialized(Int, AnyRef) A](a: A) = a
+// }
+
+
+// class Qux[@specialized(AnyRef) A] {
+// def memb[@specialized(AnyRef) B](a: A, b: B) = (a, b)
+// }
+
+
+// class Foo[@specialized(Int, AnyRef) A](val a: Array[A]) {
+// a(0)
+
+// def id(elem: A) = a(0) = elem
+// }
+
+
+// instantiation and selection
+object Test {
+ def main(arg: Array[String]) {
+ // val f = new Foo(new Array[String](5))
+ // f.id("")
+
+ // val z = new Baz[Int, Double]
+ // z.ab(1, 1.0)
+
+ testspec(new Array[String](5))
+ testspec(new Array[Int](5))
+ }
+
+ def testspec[@specialized(Int, AnyRef) T](arr: Array[T]) = arr(0)
+}
diff --git a/test/files/specialized/arrays.check b/test/files/specialized/arrays.check
new file mode 100644
index 0000000000..d37dfb720d
--- /dev/null
+++ b/test/files/specialized/arrays.check
@@ -0,0 +1,4 @@
+0
+0
+50
+51 \ No newline at end of file
diff --git a/test/files/specialized/arrays.scala b/test/files/specialized/arrays.scala
new file mode 100644
index 0000000000..505f482486
--- /dev/null
+++ b/test/files/specialized/arrays.scala
@@ -0,0 +1,55 @@
+
+
+
+import runtime.ScalaRunTime._
+
+
+class Generic[T](a: Array[T]) {
+ def apply() = a(0)
+}
+
+
+class Spec[@specialized(AnyRef) T](a: Array[T]) {
+ def apply() = a(0)
+}
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val len = 50
+
+ testSpec(new Array[String](len))
+ println(arrayApplyCount)
+
+ (new Spec(new Array[String](len)))()
+ println(arrayApplyCount)
+
+ testGeneric(new Array[String](len))
+ println(arrayApplyCount)
+
+ (new Generic(new Array[String](len)))()
+ println(arrayApplyCount)
+ }
+
+ def testGeneric[T](a: Array[T]) = {
+ var i = 0
+ var sum = 0
+ while (i < a.length) {
+ sum += (if (a(i) != null) 1 else 0)
+ i += 1
+ }
+ sum
+ }
+
+ def testSpec[@specialized(AnyRef) T](a: Array[T]) = {
+ var i = 0
+ var sum = 0
+ while (i < a.length) {
+ sum += (if (a(i) != null) 1 else 0)
+ i += 1
+ }
+ sum
+ }
+
+}
diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1
index 159d1f0db9..bc9f3a387b 100644
--- a/test/files/speclib/instrumented.jar.desired.sha1
+++ b/test/files/speclib/instrumented.jar.desired.sha1
@@ -1 +1 @@
-c3c486551044098e473d18e2c271f92d2ca7605f ?instrumented.jar
+0b7a1e1e0ee0ba8f2d3f00f3ad59eda0d2ab7eea ?instrumented.jar