diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-03-20 03:02:15 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-03-20 03:02:15 +0000 |
commit | ea94126e2dd5aa62d54ca894a785b1814c432441 (patch) | |
tree | cf51dd730619920806a8338eb115e447ddcec5a5 /test | |
parent | 1ca657a0a8e2c1d378b6344b1961042bc126e97e (diff) | |
download | scala-ea94126e2dd5aa62d54ca894a785b1814c432441.tar.gz scala-ea94126e2dd5aa62d54ca894a785b1814c432441.tar.bz2 scala-ea94126e2dd5aa62d54ca894a785b1814c432441.zip |
Merged revisions 24504-24516 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r24504 | extempore | 2011-03-19 01:31:59 +0100 (Sat, 19 Mar 2011) | 4 lines
rytz's patch for making our crazy long names a bit less crazy. You
can now use -Xmax-classfile-name to limit your filenames to as few as
72 characters. Watch out, nanotube gardens, we'll be stepping on your
tiny flowers before you know it. No review. ........ r24505 | kzys |
2011-03-19 13:14:14 +0100 (Sat, 19 Mar 2011) | 2 lines
[scaladoc] Closes #4361.
........
r24506 | kzys | 2011-03-19 14:02:35 +0100 (Sat, 19 Mar 2011) | 2 lines
[scaladoc] Closes #4357. Review by dubochet.
........
r24507 | extempore | 2011-03-19 16:27:01 +0100 (Sat, 19 Mar 2011) | 3 lines
A couple more minor tweaks to power mode, and more importantly, fix
for a jline NPE provoked if your classloaders loaded classes in a
way other than it expected. No review. ........ r24508 | extempore |
2011-03-19 16:27:19 +0100 (Sat, 19 Mar 2011) | 4 lines
Some boundary conditions in range. Also bit the bullet on getting
infix implicits to Integral and Fractional. As a bonus this patch
knocked 10,000 long boxings off a specialized test. Who knew. Closes
#4308, #4321, review by community. ........ r24509 | extempore |
2011-03-19 16:38:06 +0100 (Sat, 19 Mar 2011) | 1 line
Added a :type command to the repl, no review.
........
r24510 | extempore | 2011-03-19 18:32:37 +0100 (Sat, 19 Mar 2011) | 10 lines
Removed long deprecated and obscure CloneableCollection. Discovered
we have a scala.collection.mutable.Cloneable which does not extend
java.lang.Cloneable, which is why Array is not considered cloneable.
That seems wrong, but to be conservative I gave Array the Cloneable
interface without altering the scala trait.
Also, if @serializable is deprecated in favor of Serializable,
should not @cloneable be deprecated analogously? Closes #4307, and a
commit-question review by rytz. ........ r24511 | extempore | 2011-03-19
19:12:17 +0100 (Sat, 19 Mar 2011) | 2 lines
Fix for crasher with Class objects. Code by moors, comment by
extempore. References #4305, no review. ........ r24512 | extempore |
2011-03-19 20:55:42 +0100 (Sat, 19 Mar 2011) | 3 lines
Prevent a divergent implicit from terminating implicit search, so
that there can still be a winner, as endorsed by martin over a cheese
plate. Closes #3883, review by dmharrah. ........ r24513 | extempore |
2011-03-19 20:55:59 +0100 (Sat, 19 Mar 2011) | 3 lines
I'm going to assume the patch I dropped off five months ago for #3938
was merely overlooked. Fixes an issue with java types which extend inner
classes. Closes #3938, review by odersky. ........ r24514 | extempore |
2011-03-19 21:20:17 +0100 (Sat, 19 Mar 2011) | 1 line
Fix for a slice related array view regression. Closes #4352, no
review. ........ r24515 | extempore | 2011-03-19 21:29:02 +0100 (Sat, 19
Mar 2011) | 2 lines
Oh yeah, now I remember why I started with length overrides. Fix
for soon to be failing test, no review. ........ r24516 | extempore |
2011-03-20 00:20:19 +0100 (Sun, 20 Mar 2011) | 2 lines
Fix for a big bug in lastIndexOfSlice and some latent negative index
bugs in both that and indexOfSlice. This stuff is taxing. Closes #4348,
no review. ........
Diffstat (limited to 'test')
-rw-r--r-- | test/files/bug3938/Parent.java | 9 | ||||
-rw-r--r-- | test/files/bug3938/UseParent.scala | 7 | ||||
-rw-r--r-- | test/files/pos/array-interfaces.scala | 9 | ||||
-rw-r--r-- | test/files/pos/bug3883.scala | 15 | ||||
-rw-r--r-- | test/files/pos/bug4305.scala | 31 | ||||
-rw-r--r-- | test/files/pos/implicit-infix-ops.scala | 16 | ||||
-rw-r--r-- | test/files/run/arrayview.scala | 11 | ||||
-rw-r--r-- | test/files/run/range.scala | 14 | ||||
-rw-r--r-- | test/files/run/seqlike-kmp.check | 90 | ||||
-rw-r--r-- | test/files/run/seqlike-kmp.scala | 32 | ||||
-rw-r--r-- | test/files/specialized/fft.check | 2 |
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 |