diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-06-28 09:14:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 09:14:15 -0700 |
commit | 7a7fdac795bdee3e05cda1327a570e59fbc9ce00 (patch) | |
tree | 79568458bcabd26115d45a8f5e2a6a865d4c9a81 /test/files | |
parent | 4e950838cbee187f3cee2ef197164792db74e56a (diff) | |
parent | 1ae80e868039e4e18843ec67768002085decb763 (diff) | |
download | scala-7a7fdac795bdee3e05cda1327a570e59fbc9ce00.tar.gz scala-7a7fdac795bdee3e05cda1327a570e59fbc9ce00.tar.bz2 scala-7a7fdac795bdee3e05cda1327a570e59fbc9ce00.zip |
Merge pull request #5244 from retronym/topic/insource-scalacheck
Temporarily insource Scalacheck
Diffstat (limited to 'test/files')
6 files changed, 43 insertions, 42 deletions
diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala index 691a3e961e..605c16857a 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala @@ -44,7 +44,7 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa pa } - property("array mappings must be equal") = forAll(collectionPairs) { case (t, coll) => + property("array mappings must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield ("op index: " + ind) |: t.map(f) == coll.map(f) results.reduceLeft(_ && _) diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala index 9805e2644f..fb09a5bbb7 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala @@ -46,7 +46,7 @@ // pa.view // } -// property("forces must be equal") = forAll(collectionPairs) { case (s, coll) => +// property("forces must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => // val smodif = (s ++ s).reverse.take(s.length).reverse.zip(s).drop(s.length / 2) // val cmodif = (coll ++ s).reverse.take(s.length).reverse.zip(s).drop(s.length / 2).force // smodif == cmodif diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala index 468bcb6dd1..7e7ef2ce1b 100644 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala @@ -109,7 +109,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col println("cf == tf - " + (cf == tf)) } - property("reductions must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) => + property("reductions must be equal for assoc. operators") = forAllNoShrink(collectionPairs) { case (t, coll) => if (t.size != 0) { val results = for ((op, ind) <- reduceOperators.zipWithIndex) yield { val tr = t.reduceLeft(op) @@ -127,7 +127,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } else "has size 0" |: true } - property("counts must be equal") = forAll(collectionPairs) { case (t, coll) => + property("counts must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- countPredicates.zipWithIndex) yield { val tc = t.count(pred) val cc = coll.count(pred) @@ -143,19 +143,19 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } - property("forall must be equal") = forAll(collectionPairs) { case (t, coll) => + property("forall must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- forallPredicates.zipWithIndex) yield ("op index: " + ind) |: t.forall(pred) == coll.forall(pred) results.reduceLeft(_ && _) } - property("exists must be equal") = forAll(collectionPairs) { case (t, coll) => + property("exists must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- existsPredicates.zipWithIndex) yield ("op index: " + ind) |: t.exists(pred) == coll.exists(pred) results.reduceLeft(_ && _) } - property("both must find or not find an element") = forAll(collectionPairs) { case (t, coll) => + property("both must find or not find an element") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- findPredicates.zipWithIndex) yield { val ft = t.find(pred) val fcoll = coll.find(pred) @@ -164,7 +164,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } - property("mappings must be equal") = forAll(collectionPairs) { case (t, coll) => + property("mappings must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield { val ms = t.map(f) val mp = coll.map(f) @@ -185,7 +185,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } - property("collects must be equal") = forAll(collectionPairs) { case (t, coll) => + property("collects must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield { val ps = t.collect(f) val pp = coll.collect(f) @@ -201,12 +201,12 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } - property("flatMaps must be equal") = forAll(collectionPairs) { case (t, coll) => + property("flatMaps must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((f, ind) <- flatMapFunctions.zipWithIndex) yield ("op index: " + ind) |: areEqual(t.flatMap(f), coll.flatMap(f))).reduceLeft(_ && _) } - property("filters must be equal") = forAll(collectionPairs) { case (t, coll) => + property("filters must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((p, ind) <- filterPredicates.zipWithIndex) yield { val tf = t.filter(p) val cf = coll.filter(p) @@ -235,7 +235,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) => + property("filterNots must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((p, ind) <- filterNotPredicates.zipWithIndex) yield { val tf = t.filterNot(p) val cf = coll.filterNot(p) @@ -244,7 +244,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) => + if (!isCheckingViews) property("partitions must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((p, ind) <- partitionPredicates.zipWithIndex) yield { val tpart = t.partition(p) val cpart = coll.partition(p) @@ -258,15 +258,15 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - if (hasStrictOrder) property("takes must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => + if (hasStrictOrder) property("takes must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (t, coll, n) => ("take " + n + " elements") |: t.take(n) == coll.take(n) } - if (hasStrictOrder) property("drops must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => + if (hasStrictOrder) property("drops must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (t, coll, n) => ("drop " + n + " elements") |: t.drop(n) == coll.drop(n) } - if (hasStrictOrder) property("slices must be equal") = forAll(collectionPairsWith2Indices) + if (hasStrictOrder) property("slices must be equal") = forAllNoShrink(collectionPairsWith2Indices) { case (t, coll, fr, slicelength) => val from = if (fr < 0) 0 else fr val until = if (from + slicelength > t.size) t.size else from + slicelength @@ -290,7 +290,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("slice from " + from + " until " + until) |: tsl == collsl } - if (hasStrictOrder) property("splits must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => + if (hasStrictOrder) property("splits must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (t, coll, n) => val tspl = t.splitAt(n) val cspl = coll.splitAt(n) if (tspl != cspl) { @@ -303,7 +303,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("splitAt " + n) |: tspl == cspl } - if (hasStrictOrder) property("takeWhiles must be equal") = forAll(collectionPairs) { case (t, coll) => + if (hasStrictOrder) property("takeWhiles must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((pred, ind) <- takeWhilePredicates.zipWithIndex) yield { val tt = t.takeWhile(pred) val ct = coll.takeWhile(pred) @@ -318,7 +318,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - if (hasStrictOrder) property("spans must be equal") = forAll(collectionPairs) { case (t, coll) => + if (hasStrictOrder) property("spans must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((pred, ind) <- spanPredicates.zipWithIndex) yield { val tsp = t.span(pred) val csp = coll.span(pred) @@ -336,13 +336,13 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - if (hasStrictOrder) property("dropWhiles must be equal") = forAll(collectionPairs) { case (t, coll) => + if (hasStrictOrder) property("dropWhiles must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((pred, ind) <- dropWhilePredicates.zipWithIndex) yield { ("operator " + ind) |: t.dropWhile(pred) == coll.dropWhile(pred) }).reduceLeft(_ && _) } - property("folds must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) => + property("folds must be equal for assoc. operators") = forAllNoShrink(collectionPairs) { case (t, coll) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { val tres = t.foldLeft(first)(op) val cres = coll.fold(first)(op) @@ -389,7 +389,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } } - if (hasStrictOrder) property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) => + if (hasStrictOrder) property("copies to array must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => val tarr = newArray(t.size) val collarr = newArray(coll.size) t.copyToArray(tarr, 0, t.size) @@ -403,7 +403,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col tarr.toSeq == collarr.toSeq } - if (hasStrictOrder) property("scans must be equal") = forAll(collectionPairs) { + if (hasStrictOrder) property("scans must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { val tscan = t.scanLeft(first)(op) @@ -419,7 +419,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col }).reduceLeft(_ && _) } - property("groupBy must be equal") = forAll(collectionPairs) { + property("groupBy must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) => (for ((f, ind) <- groupByFunctions.zipWithIndex) yield { val tgroup = t.groupBy(f) diff --git a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala index d4643e7f2c..50aa4ad0c7 100644 --- a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala +++ b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala @@ -17,7 +17,7 @@ import scala.collection.parallel._ abstract class ParallelMapCheck[K, V](collname: String) extends ParallelIterableCheck[(K, V)](collname) { type CollType <: ParMap[K, V] - property("gets iterated keys") = forAll(collectionPairs) { + property("gets iterated keys") = forAllNoShrink(collectionPairs) { case (t, coll) => val containsT = for ((k, v) <- t) yield (coll.get(k) == Some(v)) val containsSelf = coll.map { case (k, v) => coll.get(k) == Some(v) } diff --git a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala index 3f8a8ad4f5..48c3d3f745 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala @@ -24,6 +24,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe def fromSeq(s: Seq[T]): CollType override def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = oneOf( + Gen.const(ofSize(vals, 1)), sized( sz => ofSize(vals, sz) @@ -74,7 +75,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe coll.patch(updateStart, coll, howMany) } - property("segmentLengths must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => + property("segmentLengths must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield { val slen = s.segmentLength(pred, if (len < 0) 0 else len) val clen = coll.segmentLength(pred, len) @@ -88,13 +89,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("prefixLengths must be equal") = forAll(collectionPairs) { case (s, coll) => + property("prefixLengths must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield { ("operator " + ind) |: s.prefixLength(pred) == coll.prefixLength(pred) }).reduceLeft(_ && _) } - property("indexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => + property("indexWheres must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- indexWherePredicates.zipWithIndex) yield { val sind = s.indexWhere(pred, len) val cind = coll.indexWhere(pred, len) @@ -109,7 +110,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("lastIndexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => + property("lastIndexWheres must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- lastIndexWherePredicates.zipWithIndex) yield { val end = if (len >= s.size) s.size - 1 else len val sind = s.lastIndexWhere(pred, end) @@ -118,7 +119,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) => + property("reverses must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => (s.length == 0 && s.getClass == classOf[collection.immutable.Range]) || { val sr = s.reverse @@ -133,13 +134,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe } } - property("reverseMaps must be equal") = forAll(collectionPairs) { case (s, coll) => + property("reverseMaps must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => (for ((f, ind) <- reverseMapFunctions.zipWithIndex) yield { ("operator " + ind) |: s.reverseMap(f) == coll.reverseMap(f) }).reduceLeft(_ && _) } - property("sameElements must be equal") = forAll(collectionPairsWithModifiedWithLengths) { + property("sameElements must be equal") = forAllNoShrink(collectionPairsWithModifiedWithLengths) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len val scm = s.sameElements(collmodif) @@ -171,7 +172,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("startsWiths must be equal") = forAll(collectionPairsWithModifiedWithLengths) { + property("startsWiths must be equal") = forAllNoShrink(collectionPairsWithModifiedWithLengths) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len ("start with self" |: s.startsWith(s) == coll.startsWith(coll)) && @@ -195,7 +196,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("endsWiths must be equal") = forAll(collectionPairsWithModified) { + property("endsWiths must be equal") = forAllNoShrink(collectionPairsWithModified) { case (s, coll, collmodif) => ("ends with self" |: s.endsWith(s) == coll.endsWith(s)) && ("ends with tail" |: (s.length == 0 || s.endsWith(s.tail) == coll.endsWith(coll.tail))) && @@ -214,7 +215,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe }).reduceLeft(_ && _) } - property("unions must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) => + property("unions must be equal") = forAllNoShrink(collectionPairsWithModified) { case (s, coll, collmodif) => ("modified" |: s.union(collmodif.seq) == coll.union(collmodif)) && ("empty" |: s.union(Nil) == coll.union(fromSeq(Nil))) } @@ -233,7 +234,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("with one" |: (s.length == 0 || s.patch(from, List(s(0)), 1) == coll.patch(from, fromSeq(List(coll(0))), 1))) } - if (!isCheckingViews) property("updates must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => + if (!isCheckingViews) property("updates must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (s, coll, len) => val pos = if (len >= s.length) s.length - 1 else len if (s.length > 0) { val supd = s.updated(pos, s(0)) @@ -248,15 +249,15 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe } else "trivially" |: true } - property("prepends must be equal") = forAll(collectionPairs) { case (s, coll) => + property("prepends must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => s.length == 0 || s(0) +: s == coll(0) +: coll } - property("appends must be equal") = forAll(collectionPairs) { case (s, coll) => + property("appends must be equal") = forAllNoShrink(collectionPairs) { case (s, coll) => s.length == 0 || s :+ s(0) == coll :+ coll(0) } - property("padTos must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => + property("padTos must be equal") = forAllNoShrink(collectionPairsWithLengths) { case (s, coll, len) => val someValue = sampleValue val sdoub = s.padTo(len * 2, someValue) val cdoub = coll.padTo(len * 2, someValue) @@ -267,10 +268,10 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe println(cdoub) } ("smaller" |: s.padTo(len / 2, someValue) == coll.padTo(len / 2, someValue)) && - ("bigger" |: sdoub == cdoub) + ("bigger" |: sdoub == cdoub) } - property("corresponds must be equal") = forAll(collectionPairsWithModified) { case (s, coll, modified) => + property("corresponds must be equal") = forAllNoShrink(collectionPairsWithModified) { case (s, coll, modified) => val modifcut = modified.toSeq.slice(0, modified.length) ("self" |: s.corresponds(s)(_ == _) == coll.corresponds(coll)(_ == _)) && ("modified" |: s.corresponds(modified.seq)(_ == _) == coll.corresponds(modified)(_ == _)) && diff --git a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala index 56f7832fed..c22dddf96d 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala @@ -17,7 +17,7 @@ import scala.collection.parallel._ abstract class ParallelSetCheck[T](collname: String) extends ParallelIterableCheck[T](collname) { type CollType <: ParSet[T] - property("gets iterated keys") = forAll(collectionPairs) { + property("gets iterated keys") = forAllNoShrink(collectionPairs) { case (t, coll) => val containsT = for (elem <- t) yield (coll.contains(elem)) val containsSelf = for (elem <- coll) yield (coll.contains(elem)) |