summaryrefslogtreecommitdiff
path: root/test/files/scalacheck
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-09-28 00:51:25 +0000
committerPaul Phillips <paulp@improving.org>2010-09-28 00:51:25 +0000
commit9c0e58c48da4cdbae7c96ef45fc15cd7aff4301f (patch)
tree857d48a844aa0479863f79c2a991984ac6a0104f /test/files/scalacheck
parenta56c33b6a470939a1396015972f09e19dc493245 (diff)
downloadscala-9c0e58c48da4cdbae7c96ef45fc15cd7aff4301f.tar.gz
scala-9c0e58c48da4cdbae7c96ef45fc15cd7aff4301f.tar.bz2
scala-9c0e58c48da4cdbae7c96ef45fc15cd7aff4301f.zip
Cleaning up the contents of test.
including "CheckEither", written against scalacheck 1.2 in the year 471 AD. Removed all the duplicates I could find, mostly between pending and files. Renamed a bunch of tests so they wouldn't look like likely duplicates next time around. Nominated somebody else to do this once in a while. No review.
Diffstat (limited to 'test/files/scalacheck')
-rw-r--r--test/files/scalacheck/CheckEither.scala194
-rw-r--r--test/files/scalacheck/array.scala37
-rw-r--r--test/files/scalacheck/list.scala21
-rw-r--r--test/files/scalacheck/primitive-eqeq.scala37
-rw-r--r--test/files/scalacheck/range.scala206
-rw-r--r--test/files/scalacheck/scan.scala17
-rw-r--r--test/files/scalacheck/substringTests.scala (renamed from test/files/scalacheck/test2.scala)0
7 files changed, 512 insertions, 0 deletions
diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala
new file mode 100644
index 0000000000..0651b90b2e
--- /dev/null
+++ b/test/files/scalacheck/CheckEither.scala
@@ -0,0 +1,194 @@
+import org.scalacheck.{ Arbitrary, ConsoleReporter, Prop, Properties }
+import org.scalacheck.Arbitrary.{arbitrary, arbThrowable}
+import org.scalacheck.Gen.oneOf
+import org.scalacheck.util.StdRand
+import org.scalacheck.Prop._
+import org.scalacheck.ConsoleReporter.{testReport, propReport}
+import org.scalacheck.Test.{Params, check}
+import org.scalacheck.ConsoleReporter.testStatsEx
+import Function.tupled
+
+object CheckEither extends Properties("Either") {
+ implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] =
+ Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_))))
+
+ val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n)
+
+ val prop_either2 = forAll((n: Int) => Right(n).fold(a => error("fail"), x => x) == n)
+
+ val prop_swap = forAll((e: Either[Int, Int]) => e match {
+ case Left(a) => e.swap.right.get == a
+ case Right(b) => e.swap.left.get == b
+ })
+
+ val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight)
+
+ object CheckLeftProjection {
+ val prop_value = forAll((n: Int) => Left(n).left.get == n)
+
+ val prop_getOrElse = forAll((e: Either[Int, Int], or: Int) => e.left.getOrElse(or) == (e match {
+ case Left(a) => a
+ case Right(_) => or
+ }))
+
+ val prop_forall = forAll((e: Either[Int, Int]) =>
+ e.left.forall(_ % 2 == 0) == (e.isRight || e.left.get % 2 == 0))
+
+ val prop_exists = forAll((e: Either[Int, Int]) =>
+ e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0))
+
+ val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => {
+ def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s)
+ Left(n).left.flatMap(f(_)) == f(n)})
+
+ val prop_flatMapRightIdentity = forAll((e: Either[Int, Int]) => e.left.flatMap(Left(_)) == e)
+
+ val prop_flatMapComposition = forAll((e: Either[Int, Int]) => {
+ def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x)
+ def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x)
+ e.left.flatMap(f(_)).left.flatMap(g(_)) == e.left.flatMap(f(_).left.flatMap(g(_)))})
+
+ val prop_mapIdentity = forAll((e: Either[Int, Int]) => e.left.map(x => x) == e)
+
+ val prop_mapComposition = forAll((e: Either[String, Int]) => {
+ def f(s: String) = s.toLowerCase
+ def g(s: String) = s.reverse
+ e.left.map(x => f(g(x))) == e.left.map(x => g(x)).left.map(f(_))})
+
+ val prop_filter = forAll((e: Either[Int, Int], x: Int) => e.left.filter(_ % 2 == 0) ==
+ (if(e.isRight || e.left.get % 2 != 0) None else Some(e)))
+
+ val prop_seq = forAll((e: Either[Int, Int]) => e.left.toSeq == (e match {
+ case Left(a) => Seq(a)
+ case Right(_) => Seq.empty
+ }))
+
+ val prop_option = forAll((e: Either[Int, Int]) => e.left.toOption == (e match {
+ case Left(a) => Some(a)
+ case Right(_) => None
+ }))
+ }
+
+ object CheckRightProjection {
+ val prop_value = forAll((n: Int) => Right(n).right.get == n)
+
+ val prop_getOrElse = forAll((e: Either[Int, Int], or: Int) => e.right.getOrElse(or) == (e match {
+ case Left(_) => or
+ case Right(b) => b
+ }))
+
+ val prop_forall = forAll((e: Either[Int, Int]) =>
+ e.right.forall(_ % 2 == 0) == (e.isLeft || e.right.get % 2 == 0))
+
+ val prop_exists = forAll((e: Either[Int, Int]) =>
+ e.right.exists(_ % 2 == 0) == (e.isRight && e.right.get % 2 == 0))
+
+ val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => {
+ def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s)
+ Right(n).right.flatMap(f(_)) == f(n)})
+
+ val prop_flatMapRightIdentity = forAll((e: Either[Int, Int]) => e.right.flatMap(Right(_)) == e)
+
+ val prop_flatMapComposition = forAll((e: Either[Int, Int]) => {
+ def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x)
+ def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x)
+ e.right.flatMap(f(_)).right.flatMap(g(_)) == e.right.flatMap(f(_).right.flatMap(g(_)))})
+
+ val prop_mapIdentity = forAll((e: Either[Int, Int]) => e.right.map(x => x) == e)
+
+ val prop_mapComposition = forAll((e: Either[Int, String]) => {
+ def f(s: String) = s.toLowerCase
+ def g(s: String) = s.reverse
+ e.right.map(x => f(g(x))) == e.right.map(x => g(x)).right.map(f(_))})
+
+ val prop_filter = forAll((e: Either[Int, Int], x: Int) => e.right.filter(_ % 2 == 0) ==
+ (if(e.isLeft || e.right.get % 2 != 0) None else Some(e)))
+
+ val prop_seq = forAll((e: Either[Int, Int]) => e.right.toSeq == (e match {
+ case Left(_) => Seq.empty
+ case Right(b) => Seq(b)
+ }))
+
+ val prop_option = forAll((e: Either[Int, Int]) => e.right.toOption == (e match {
+ case Left(_) => None
+ case Right(b) => Some(b)
+ }))
+ }
+
+ val prop_Either_left = forAll((n: Int) => Left(n).left.get == n)
+
+ val prop_Either_right = forAll((n: Int) => Right(n).right.get == n)
+
+ val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match {
+ case Left(ee) => e.joinLeft == ee
+ case Right(n) => e.joinLeft == Right(n)
+ })
+
+ val prop_Either_joinRight = forAll((e: Either[Int, Either[Int, Int]]) => e match {
+ case Left(n) => e.joinRight == Left(n)
+ case Right(ee) => e.joinRight == ee
+ })
+
+ val prop_Either_reduce = forAll((e: Either[Int, Int]) =>
+ e.merge == (e match {
+ case Left(a) => a
+ case Right(a) => a
+ }))
+
+ /** Hard to believe I'm "fixing" a test to reflect B before A ... */
+ val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) =>
+ Either.cond(c, a, b) == (if(c) Right(a) else Left(b)))
+
+ val tests = List(
+ ("prop_either1", prop_either1),
+ ("prop_either2", prop_either2),
+ ("prop_swap", prop_swap),
+ ("prop_isLeftRight", prop_isLeftRight),
+ ("Left.prop_value", CheckLeftProjection.prop_value),
+ ("Left.prop_getOrElse", CheckLeftProjection.prop_getOrElse),
+ ("Left.prop_forall", CheckLeftProjection.prop_forall),
+ ("Left.prop_exists", CheckLeftProjection.prop_exists),
+ ("Left.prop_flatMapLeftIdentity", CheckLeftProjection.prop_flatMapLeftIdentity),
+ ("Left.prop_flatMapRightIdentity", CheckLeftProjection.prop_flatMapRightIdentity),
+ ("Left.prop_flatMapComposition", CheckLeftProjection.prop_flatMapComposition),
+ ("Left.prop_mapIdentity", CheckLeftProjection.prop_mapIdentity),
+ ("Left.prop_mapComposition", CheckLeftProjection.prop_mapComposition),
+ ("Left.prop_filter", CheckLeftProjection.prop_filter),
+ ("Left.prop_seq", CheckLeftProjection.prop_seq),
+ ("Left.prop_option", CheckLeftProjection.prop_option),
+ ("Right.prop_value", CheckRightProjection.prop_value),
+ ("Right.prop_getOrElse", CheckRightProjection.prop_getOrElse),
+ ("Right.prop_forall", CheckRightProjection.prop_forall),
+ ("Right.prop_exists", CheckRightProjection.prop_exists),
+ ("Right.prop_flatMapLeftIdentity", CheckRightProjection.prop_flatMapLeftIdentity),
+ ("Right.prop_flatMapRightIdentity", CheckRightProjection.prop_flatMapRightIdentity),
+ ("Right.prop_flatMapComposition", CheckRightProjection.prop_flatMapComposition),
+ ("Right.prop_mapIdentity", CheckRightProjection.prop_mapIdentity),
+ ("Right.prop_mapComposition", CheckRightProjection.prop_mapComposition),
+ ("Right.prop_filter", CheckRightProjection.prop_filter),
+ ("Right.prop_seq", CheckRightProjection.prop_seq),
+ ("Right.prop_option", CheckRightProjection.prop_option),
+ ("prop_Either_left", prop_Either_left),
+ ("prop_Either_right", prop_Either_right),
+ ("prop_Either_joinLeft", prop_Either_joinLeft),
+ ("prop_Either_joinRight", prop_Either_joinRight),
+ ("prop_Either_reduce", prop_Either_reduce),
+ ("prop_Either_cond", prop_Either_cond)
+ )
+
+ for ((label, prop) <- tests) {
+ property(label) = prop
+ }
+
+ import org.scalacheck.{ Test => STest }
+
+ def runTests() = {
+ STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this)
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ CheckEither.runTests()
+ }
+}
diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array.scala
new file mode 100644
index 0000000000..03c0217180
--- /dev/null
+++ b/test/files/scalacheck/array.scala
@@ -0,0 +1,37 @@
+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/list.scala b/test/files/scalacheck/list.scala
new file mode 100644
index 0000000000..1caf35e872
--- /dev/null
+++ b/test/files/scalacheck/list.scala
@@ -0,0 +1,21 @@
+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/primitive-eqeq.scala b/test/files/scalacheck/primitive-eqeq.scala
new file mode 100644
index 0000000000..60fe63c207
--- /dev/null
+++ b/test/files/scalacheck/primitive-eqeq.scala
@@ -0,0 +1,37 @@
+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/range.scala b/test/files/scalacheck/range.scala
new file mode 100644
index 0000000000..b14177e38b
--- /dev/null
+++ b/test/files/scalacheck/range.scala
@@ -0,0 +1,206 @@
+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") {
+ import org.scalacheck.{ Test => STest }
+
+ List(NormalRangeTest, InclusiveRangeTest, ByOneRangeTest, InclusiveByOneRangeTest) foreach { ps =>
+ STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), ps)
+ }
+}
+
+/* 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
new file mode 100644
index 0000000000..e9b25ce3df
--- /dev/null
+++ b/test/files/scalacheck/scan.scala
@@ -0,0 +1,17 @@
+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
+ }}
+}
+
+
+
+
+
+
diff --git a/test/files/scalacheck/test2.scala b/test/files/scalacheck/substringTests.scala
index 2cb5fc0498..2cb5fc0498 100644
--- a/test/files/scalacheck/test2.scala
+++ b/test/files/scalacheck/substringTests.scala