summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/bug3938/Parent.java9
-rw-r--r--test/files/bug3938/UseParent.scala7
-rw-r--r--test/files/pos/array-interfaces.scala9
-rw-r--r--test/files/pos/bug3883.scala15
-rw-r--r--test/files/pos/bug4305.scala31
-rw-r--r--test/files/pos/implicit-infix-ops.scala16
-rw-r--r--test/files/run/arrayview.scala11
-rw-r--r--test/files/run/range.scala14
-rw-r--r--test/files/run/seqlike-kmp.check90
-rw-r--r--test/files/run/seqlike-kmp.scala32
-rw-r--r--test/files/specialized/fft.check2
11 files changed, 235 insertions, 1 deletions
diff --git a/test/files/bug3938/Parent.java b/test/files/bug3938/Parent.java
new file mode 100644
index 0000000000..08fae330bb
--- /dev/null
+++ b/test/files/bug3938/Parent.java
@@ -0,0 +1,9 @@
+public class Parent<A>{
+ class I1 {}
+ class I2 extends Parent.I1 {}
+
+ // OKAY:
+ class I3 extends I1 {}
+ static class I4 {}
+ static class I5 extends Parent.I4 {}
+}
diff --git a/test/files/bug3938/UseParent.scala b/test/files/bug3938/UseParent.scala
new file mode 100644
index 0000000000..685d1a03a8
--- /dev/null
+++ b/test/files/bug3938/UseParent.scala
@@ -0,0 +1,7 @@
+object UseParent {
+ classOf[Parent[AnyRef]#I2]
+
+ // OKAY
+ classOf[Parent[AnyRef]#I3]
+ classOf[Parent.I5]
+}
diff --git a/test/files/pos/array-interfaces.scala b/test/files/pos/array-interfaces.scala
new file mode 100644
index 0000000000..70cafd2bb1
--- /dev/null
+++ b/test/files/pos/array-interfaces.scala
@@ -0,0 +1,9 @@
+object s {
+ def f(x: Cloneable) = ()
+ def g(x: java.io.Serializable) = ()
+
+ def main(args: Array[String]): Unit = {
+ f(args)
+ g(args)
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/bug3883.scala b/test/files/pos/bug3883.scala
new file mode 100644
index 0000000000..adde0526b2
--- /dev/null
+++ b/test/files/pos/bug3883.scala
@@ -0,0 +1,15 @@
+// need to test both orders
+object A1 {
+ implicit def i: Equiv[Boolean] = error("")
+ implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("")
+
+ implicitly[Equiv[Boolean]]
+}
+
+object A2 {
+ implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("")
+ implicit def i: Equiv[Boolean] = error("")
+
+ implicitly[Equiv[Boolean]]
+}
+
diff --git a/test/files/pos/bug4305.scala b/test/files/pos/bug4305.scala
new file mode 100644
index 0000000000..ba3eb65bc1
--- /dev/null
+++ b/test/files/pos/bug4305.scala
@@ -0,0 +1,31 @@
+object T1 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ classOf[C].getTypeParameters
+ }
+ }
+}
+
+object T2 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ val x = classOf[C]
+ x.getTypeParameters
+ }
+ }
+}
+
+object T3 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ val x: Class[C] = classOf[C]
+ x.getTypeParameters
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/implicit-infix-ops.scala b/test/files/pos/implicit-infix-ops.scala
index ef4512fa6b..66f3718e86 100644
--- a/test/files/pos/implicit-infix-ops.scala
+++ b/test/files/pos/implicit-infix-ops.scala
@@ -5,3 +5,19 @@ object Test {
def f1[T: Numeric](x: T, y: T, z: T) = x + y + z
def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z)
}
+
+object Int {
+ import Ordering.Implicits._
+ import math.Integral.Implicits._
+
+ def f1[T: Integral](x: T, y: T, z: T) = (x + y + z) / z
+ def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z)
+}
+
+object Frac {
+ import Ordering.Implicits._
+ import math.Fractional.Implicits._
+
+ def f1[T: Fractional](x: T, y: T, z: T) = (x + y + z) / z
+ def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z)
+} \ No newline at end of file
diff --git a/test/files/run/arrayview.scala b/test/files/run/arrayview.scala
new file mode 100644
index 0000000000..97e840f5e9
--- /dev/null
+++ b/test/files/run/arrayview.scala
@@ -0,0 +1,11 @@
+object Test {
+ def f = (1 to 100).toArray.view
+
+ def main(args: Array[String]): Unit = {
+ val xs = (f filter (_ < 50)).reverse.filter(_ % 2 == 0).map(_ / 2).flatMap(x => Array(1, x))
+ assert(xs.size == 48)
+ val ys = xs.toArray
+ assert(ys.size == 48)
+ assert(xs.sum == ys.sum)
+ }
+}
diff --git a/test/files/run/range.scala b/test/files/run/range.scala
index 31d90f2d6d..2dc0bae330 100644
--- a/test/files/run/range.scala
+++ b/test/files/run/range.scala
@@ -7,6 +7,17 @@ object Test {
assert(buffer.toList == range.iterator.toList, buffer.toList+"/"+range.iterator.toList)
}
+ def boundaryTests() = {
+ // #4321
+ assert((Int.MinValue to Int.MaxValue by Int.MaxValue).size == 3)
+ // #4308
+ val caught = (
+ try { (Long.MinValue to Long.MaxValue).sum ; false }
+ catch { case _: IllegalArgumentException => true }
+ )
+ assert(caught)
+ }
+
case class GR[T](val x: T)(implicit val num: Integral[T]) {
import num._
@@ -54,5 +65,8 @@ object Test {
rangeForeach(10 until 1 by -1);
rangeForeach(10 to 1 by -3);
rangeForeach(10 until 1 by -3);
+
+ // living on the edges
+ boundaryTests()
}
}
diff --git a/test/files/run/seqlike-kmp.check b/test/files/run/seqlike-kmp.check
new file mode 100644
index 0000000000..6040710c7c
--- /dev/null
+++ b/test/files/run/seqlike-kmp.check
@@ -0,0 +1,90 @@
+indexOfSlice
+ (97) with idx >= -1 = 97
+ (97) with idx >= 0 = 97
+ (97) with idx >= 1 = 97
+ (97) with idx >= 2 = 97
+ (97) with idx >= 97 = 97
+ (97) with idx >= 98 = -1
+ (97) with idx >= 99 = -1
+ (97) with idx >= 100 = -1
+lastIndexOfSlice
+ (97) with idx <= -1 = -1
+ (97) with idx <= 0 = -1
+ (97) with idx <= 1 = -1
+ (97) with idx <= 2 = -1
+ (97) with idx <= 97 = 97
+ (97) with idx <= 98 = 97
+ (97) with idx <= 99 = 97
+ (97) with idx <= 100 = 97
+indexOfSlice
+ (97, 98) with idx >= -1 = 97
+ (97, 98) with idx >= 0 = 97
+ (97, 98) with idx >= 1 = 97
+ (97, 98) with idx >= 2 = 97
+ (97, 98) with idx >= 97 = 97
+ (97, 98) with idx >= 98 = -1
+ (97, 98) with idx >= 99 = -1
+ (97, 98) with idx >= 100 = -1
+lastIndexOfSlice
+ (97, 98) with idx <= -1 = -1
+ (97, 98) with idx <= 0 = -1
+ (97, 98) with idx <= 1 = -1
+ (97, 98) with idx <= 2 = -1
+ (97, 98) with idx <= 97 = 97
+ (97, 98) with idx <= 98 = 97
+ (97, 98) with idx <= 99 = 97
+ (97, 98) with idx <= 100 = 97
+indexOfSlice
+ (97, 98, 99) with idx >= -1 = 97
+ (97, 98, 99) with idx >= 0 = 97
+ (97, 98, 99) with idx >= 1 = 97
+ (97, 98, 99) with idx >= 2 = 97
+ (97, 98, 99) with idx >= 97 = 97
+ (97, 98, 99) with idx >= 98 = -1
+ (97, 98, 99) with idx >= 99 = -1
+ (97, 98, 99) with idx >= 100 = -1
+lastIndexOfSlice
+ (97, 98, 99) with idx <= -1 = -1
+ (97, 98, 99) with idx <= 0 = -1
+ (97, 98, 99) with idx <= 1 = -1
+ (97, 98, 99) with idx <= 2 = -1
+ (97, 98, 99) with idx <= 97 = 97
+ (97, 98, 99) with idx <= 98 = 97
+ (97, 98, 99) with idx <= 99 = 97
+ (97, 98, 99) with idx <= 100 = 97
+indexOfSlice
+ (98, 99) with idx >= -1 = 98
+ (98, 99) with idx >= 0 = 98
+ (98, 99) with idx >= 1 = 98
+ (98, 99) with idx >= 2 = 98
+ (98, 99) with idx >= 97 = 98
+ (98, 99) with idx >= 98 = 98
+ (98, 99) with idx >= 99 = -1
+ (98, 99) with idx >= 100 = -1
+lastIndexOfSlice
+ (98, 99) with idx <= -1 = -1
+ (98, 99) with idx <= 0 = -1
+ (98, 99) with idx <= 1 = -1
+ (98, 99) with idx <= 2 = -1
+ (98, 99) with idx <= 97 = -1
+ (98, 99) with idx <= 98 = 98
+ (98, 99) with idx <= 99 = 98
+ (98, 99) with idx <= 100 = 98
+indexOfSlice
+ (99) with idx >= -1 = 99
+ (99) with idx >= 0 = 99
+ (99) with idx >= 1 = 99
+ (99) with idx >= 2 = 99
+ (99) with idx >= 97 = 99
+ (99) with idx >= 98 = 99
+ (99) with idx >= 99 = 99
+ (99) with idx >= 100 = -1
+lastIndexOfSlice
+ (99) with idx <= -1 = -1
+ (99) with idx <= 0 = -1
+ (99) with idx <= 1 = -1
+ (99) with idx <= 2 = -1
+ (99) with idx <= 97 = -1
+ (99) with idx <= 98 = -1
+ (99) with idx <= 99 = 99
+ (99) with idx <= 100 = 99
diff --git a/test/files/run/seqlike-kmp.scala b/test/files/run/seqlike-kmp.scala
new file mode 100644
index 0000000000..af39fda9af
--- /dev/null
+++ b/test/files/run/seqlike-kmp.scala
@@ -0,0 +1,32 @@
+object Test {
+ val source = 0 to 99
+ val idxes = (-1 to 2) ++ (97 to 100)
+ def str(xs: Seq[Int]) = xs.mkString("(", ", ", ")")
+
+ def f(tgt: Seq[Int]) = {
+ println("indexOfSlice")
+ // the first index `>= from` such that...
+ for (x <- idxes) {
+ val res = source.indexOfSlice(tgt, x)
+ println(" %s with idx >= %d = %d".format(str(tgt), x, res))
+ }
+ // the last index `<= end` such that...
+ println("lastIndexOfSlice")
+ for (x <- idxes) {
+ val res = source.lastIndexOfSlice(tgt, x)
+ println(" %s with idx <= %d = %d".format(str(tgt), x, res))
+ }
+ }
+
+ def g(idx: Int, len: Int) = {
+ f(source.slice(idx, idx + len))
+ }
+
+ def main(args: Array[String]): Unit = {
+ g(97, 1)
+ g(97, 2)
+ g(97, 3)
+ g(98, 2)
+ g(99, 1)
+ }
+}
diff --git a/test/files/specialized/fft.check b/test/files/specialized/fft.check
index eb56a2a879..69a3a61f36 100644
--- a/test/files/specialized/fft.check
+++ b/test/files/specialized/fft.check
@@ -1,4 +1,4 @@
Processing 65536 items
Boxed doubles: 0
Boxed ints: 2
-Boxed longs: 1442031
+Boxed longs: 1310921