diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-05-12 07:45:22 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-05-12 07:45:22 +0000 |
commit | c932ec58f9e6fc90c9497bb4cbfb09f2b398e7ea (patch) | |
tree | 1bbb00aca2f6bc710a8cc1d25e61153f261496b2 /test/files | |
parent | 64609f93548ea7637718057b23d0fb19d998e812 (diff) | |
download | scala-c932ec58f9e6fc90c9497bb4cbfb09f2b398e7ea.tar.gz scala-c932ec58f9e6fc90c9497bb4cbfb09f2b398e7ea.tar.bz2 scala-c932ec58f9e6fc90c9497bb4cbfb09f2b398e7ea.zip |
Merged revisions 21881-21882,21884-21886,21888,...
Merged revisions
21881-21882,21884-21886,21888,21891,21897-21898,21901,21908 via svnmerge
from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r21881 | dragos | 2010-05-10 17:36:17 +0200 (Mon, 10 May 2010) | 1 line
Fixed -Xcheckinit build.no review.
........
r21882 | odersky | 2010-05-10 17:40:08 +0200 (Mon, 10 May 2010) | 1 line
Disabled scalacheck tests because they interfere with library
refactorings (refactorings break scalacheck). ........ r21884 | odersky
| 2010-05-10 17:50:23 +0200 (Mon, 10 May 2010) | 1 line
made MathCommon a class to gain some speed.
........
r21885 | odersky | 2010-05-10 17:51:46 +0200 (Mon, 10 May 2010) | 1 line
Made builder in MutableMapFactory use += instead of +. ........ r21886
| odersky | 2010-05-10 17:52:25 +0200 (Mon, 10 May 2010) | 1 line
Added sizeHints to operations where it made sense. Made sizeHint
interface more flexible. ........ r21888 | dragos | 2010-05-10 18:21:40
+0200 (Mon, 10 May 2010) | 1 line
Closed #3413. No review.
........
r21891 | rytz | 2010-05-10 19:16:02 +0200 (Mon, 10 May 2010) | 1 line
close #3415. relates to r21680. review by milessabin. ........ r21897
| odersky | 2010-05-11 11:34:56 +0200 (Tue, 11 May 2010) | 1 line
Closes #t3363. Review by extempore.
........
r21898 | odersky | 2010-05-11 11:35:30 +0200 (Tue, 11 May 2010) | 1 line
Corrected sizeHints for scanLeft/Right
........
r21901 | milessabin | 2010-05-11 14:42:21 +0200 (Tue, 11 May 2010) | 1 line
Fix from Mirko Stocker and unit test for #3416. Review by plocinic.
........ r21908 | rytz | 2010-05-12 09:19:48 +0200 (Wed, 12 May 2010) |
1 line
new msil.jar to make msil build. noreview.
........
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/t3415/Hello.java | 3 | ||||
-rw-r--r-- | test/files/jvm/t3415/HelloWorld.scala | 4 | ||||
-rwxr-xr-x | test/files/pos/t3363.scala | 18 | ||||
-rw-r--r-- | test/files/positions/Overlap7.scala | 3 | ||||
-rw-r--r-- | test/files/scalacheck/array.scala | 37 | ||||
-rw-r--r-- | test/files/scalacheck/eqeq.scala | 37 | ||||
-rw-r--r-- | test/files/scalacheck/list.scala | 21 | ||||
-rw-r--r-- | test/files/scalacheck/range.scala | 205 | ||||
-rw-r--r-- | test/files/scalacheck/scan.scala | 17 |
9 files changed, 28 insertions, 317 deletions
diff --git a/test/files/jvm/t3415/Hello.java b/test/files/jvm/t3415/Hello.java new file mode 100644 index 0000000000..ae7206453b --- /dev/null +++ b/test/files/jvm/t3415/Hello.java @@ -0,0 +1,3 @@ +public @interface Hello { + String msg() default "hoi"; +} diff --git a/test/files/jvm/t3415/HelloWorld.scala b/test/files/jvm/t3415/HelloWorld.scala new file mode 100644 index 0000000000..53bf55e444 --- /dev/null +++ b/test/files/jvm/t3415/HelloWorld.scala @@ -0,0 +1,4 @@ +object Test extends Application { + @Hello + def foo() { } +} diff --git a/test/files/pos/t3363.scala b/test/files/pos/t3363.scala new file mode 100755 index 0000000000..bae54084ea --- /dev/null +++ b/test/files/pos/t3363.scala @@ -0,0 +1,18 @@ +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: Manifest[T] = error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]) { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/test/files/positions/Overlap7.scala b/test/files/positions/Overlap7.scala new file mode 100644 index 0000000000..b3dc0d10e2 --- /dev/null +++ b/test/files/positions/Overlap7.scala @@ -0,0 +1,3 @@ +import java.lang.String, java.lang.Object + +class Overlap7 diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array.scala deleted file mode 100644 index 03c0217180..0000000000 --- a/test/files/scalacheck/array.scala +++ /dev/null @@ -1,37 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ -import Arbitrary._ -import util._ -import Buildable._ -import scala.collection.mutable.ArraySeq - -object Test extends Properties("Array") { - /** At this moment the authentic scalacheck Array Builder/Arb bits are commented out. - */ - implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = - Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) - - val arrGen: Gen[Array[_]] = oneOf( - arbitrary[Array[Int]], - arbitrary[Array[Array[Int]]], - arbitrary[Array[List[String]]], - arbitrary[Array[String]], - arbitrary[Array[Boolean]], - arbitrary[Array[AnyVal]] - ) - - // inspired by #1857 and #2352 - property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => - (c1 eq c2) || (c1 ne c2) - } - - // inspired by #2299 - def smallInt = choose(1, 10) - property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) => - val arr = Array.ofDim[String](i1, i2, i3) - val flattened = arr flatMap (x => x) flatMap (x => x) - flattened.length == i1 * i2 * i3 - } -} - diff --git a/test/files/scalacheck/eqeq.scala b/test/files/scalacheck/eqeq.scala deleted file mode 100644 index 60fe63c207..0000000000 --- a/test/files/scalacheck/eqeq.scala +++ /dev/null @@ -1,37 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -object Test extends Properties("==") { - def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) - - // ticket #2087 - property("short/char") = forAll { (x: Short) => { - val ch: Char = x.toChar - (x == ch) == (ch == x) - } - } - - property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } - property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } - - property("##") = forAll { - (x: Short) => { - val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) - val shortAndLarger = anyvals drop 2 - - val result = ( - ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && - ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && - ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) - ) - result - } - } - property("## 2") = forAll { - (dv: Double) => { - val fv = dv.toFloat - (fv != dv) || (fv.## == dv.##) - } - } -} diff --git a/test/files/scalacheck/list.scala b/test/files/scalacheck/list.scala deleted file mode 100644 index 1caf35e872..0000000000 --- a/test/files/scalacheck/list.scala +++ /dev/null @@ -1,21 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -object Test extends Properties("List") { - def sorted(xs: List[Int]) = xs sortWith (_ < _) - - property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => (l1.size + l2.size) == (l1 ::: l2).size } - property("reverse") = forAll { (l1: List[Int]) => l1.reverse.reverse == l1 } - property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).distinct } - property("flatten") = forAll { (xxs: List[List[Int]]) => xxs.flatten.length == (xxs map (_.length) sum) } - property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } - property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } - property("fill") = forAll(choose(1, 100)) { count => - forAll { (x: Int) => - val xs = List.fill(count)(x) - (xs.length == count) && (xs.distinct == List(x)) - } - } -} - diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala deleted file mode 100644 index faa1f5d479..0000000000 --- a/test/files/scalacheck/range.scala +++ /dev/null @@ -1,205 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ -import Arbitrary._ - -class Counter(r: Range) { - var cnt = 0L - var last: Option[Int] = None - val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - def apply(x: Int) = { - cnt += 1L - if (cnt % 500000000L == 0L) { - println("Working: %s %d %d" format (str, cnt, x)) - } - if (cnt > (Int.MaxValue.toLong + 1) * 2) - error("Count exceeds maximum possible for an Int Range") - if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x))) - error("Range wrapped: %d %s" format (x, last.toString)) - last = Some(x) - } -} - -abstract class RangeTest(kind: String) extends Properties("Range "+kind) { - def myGen: Gen[Range] - - val genRange = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - step <- Gen.choose(1, (start - end).abs + 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genReasonableSizeRange = for { - start <- choose(-Int.MinValue, Int.MaxValue) - end <- choose(-Int.MinValue, Int.MaxValue) - step <- choose(-Int.MaxValue, Int.MaxValue) - } yield Range(start, end, if (step == 0) 100 else step) - - val genSmallRange = for { - start <- choose(-100, 100) - end <- choose(-100, 100) - step <- choose(1, 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genRangeByOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (end.toLong - start.toLong).abs <= 10000000L - } yield if (start < end) Range(start, end) else Range(end, start) - - def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - - def expectedSize(r: Range): Long = if (r.isInclusive) { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L - case _ => if (r.start == r.end) 1L else 0L - } - } else { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => ( - (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong - + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L) - ) - case _ => 0L - } - } - - def within(r: Range, x: Int) = if (r.step > 0) - r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end) - else - r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end) - - def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0 - - property("foreach.step") = forAll(myGen) { r => - var allValid = true - val cnt = new Counter(r) -// println("--------------------") -// println(r) - r foreach { x => cnt(x) -// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step)) - allValid &&= multiple(r, x) - } - allValid :| str(r) - } - - property("foreach.inside.range") = forAll(myGen) { r => - var allValid = true - var last: Option[Int] = None - val cnt = new Counter(r) - r foreach { x => cnt(x) - allValid &&= within(r, x) - } - allValid :| str(r) - } - - property("foreach.visited.size") = forAll(myGen) { r => - var visited = 0L - val cnt = new Counter(r) - r foreach { x => cnt(x) - visited += 1L - } -// println("----------") -// println(str(r)) -// println("size: " + r.size) -// println("expected: " + expectedSize(r)) -// println("visited: " + visited) - (visited == expectedSize(r)) :| str(r) - } - - property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.length == expectedSize(r)) :| str(r) - } - - property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.isEmpty == (expectedSize(r) == 0L)) :| str(r) - } - - property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) => -// println("----------------") -// println(str(r)) -// println(x) -// println("within: " + within(r, x)) -// println("multiple: " + multiple(r, x)) -// println("contains: " + r.contains(x)) - ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x - } - - property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = r take x - (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x - } - - property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) - if (r.size == 0) { - (t.size == 0) :| str(r)+" / "+str(t)+": "+x - } else { - val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive) - (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x - } - } - - property("reverse.toSet.equal") = forAll(myGen) { r => - val reversed = r.reverse - val aresame = r.toSet == reversed.toSet - if (!aresame) { - println(str(r)) - println(r) - println(reversed) - println(r.toSet) - println(reversed.toSet) - } - aresame - } -} - -object NormalRangeTest extends RangeTest("normal") { - override def myGen = genReasonableSizeRange - def genOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (start.toLong - end.toLong).abs < Int.MaxValue.toLong - } yield Range(start, end, if (start < end) 1 else - 1) - property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r => - (r.size + 1 == r.inclusive.size) :| str(r) - } -} - -object InclusiveRangeTest extends RangeTest("inclusive") { - override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive -} - -object ByOneRangeTest extends RangeTest("byOne") { - override def myGen = genSmallRange -} - -object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") { - override def myGen = for (r <- genSmallRange) yield r.inclusive -} - -object SmallValuesRange extends RangeTest("smallValues") { - override def myGen = genSmallRange -} - -object Test extends Properties("Range") { - include(NormalRangeTest) - include(InclusiveRangeTest) - include(ByOneRangeTest) - include(InclusiveByOneRangeTest) -} - -/* Mini-benchmark -def testRange(i: Int, j: Int, k: Int) = { - var count = 0 - for { - vi <- 0 to i - vj <- 0 to j - vk <- 0 to k - } { count += 1 } -} - -testRange(10, 1000, 10000) -testRange(10000, 1000, 10) -*/ - diff --git a/test/files/scalacheck/scan.scala b/test/files/scalacheck/scan.scala deleted file mode 100644 index e9b25ce3df..0000000000 --- a/test/files/scalacheck/scan.scala +++ /dev/null @@ -1,17 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - - -object Test extends Properties("TraversableLike.scanLeft") { - property("scanLeft") = forAll { (xs: List[Int], z: Int) => { - val sums = xs.scanLeft(z)(_ + _) - (xs.size == 0) || sums.zip(sums.tail).map(x => x._2 - x._1) == xs - }} -} - - - - - - |