An issue with scalacheck and actors where an excess of thread pools gets created - tmp fix. No review.
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@23193 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
cb10c89599
commit
6143f47005
|
@ -156,7 +156,8 @@ object Test {
|
||||||
* the test results. */
|
* the test results. */
|
||||||
def check(prms: Params, p: Prop): Result = {
|
def check(prms: Params, p: Prop): Result = {
|
||||||
import prms._
|
import prms._
|
||||||
import actors.Futures.future
|
//import actors.Futures.future
|
||||||
|
import scala.concurrent.ops.future
|
||||||
|
|
||||||
assertParams(prms)
|
assertParams(prms)
|
||||||
if(workers > 1)
|
if(workers > 1)
|
||||||
|
|
|
@ -8,7 +8,7 @@ object Test extends Properties("List") {
|
||||||
property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => (l1.size + l2.size) == (l1 ::: l2).size }
|
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("reverse") = forAll { (l1: List[Int]) => l1.reverse.reverse == l1 }
|
||||||
property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).distinct }
|
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("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("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("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) }
|
||||||
property("fill") = forAll(choose(1, 100)) { count =>
|
property("fill") = forAll(choose(1, 100)) { count =>
|
||||||
|
|
|
@ -39,11 +39,11 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa
|
||||||
pa
|
pa
|
||||||
}
|
}
|
||||||
|
|
||||||
// property("array mappings must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("array mappings must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((f, ind) <- mapFunctions.zipWithIndex)
|
val results = for ((f, ind) <- mapFunctions.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.map(f) == coll.map(f)
|
yield ("op index: " + ind) |: t.map(f) == coll.map(f)
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,218 +49,218 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col
|
||||||
(inst, fromTraversable(inst), modif)
|
(inst, fromTraversable(inst), modif)
|
||||||
}
|
}
|
||||||
|
|
||||||
// property("reductions must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) =>
|
property("reductions must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// if (t.size != 0) {
|
if (t.size != 0) {
|
||||||
// val results = for ((op, ind) <- reduceOperators.zipWithIndex) yield {
|
val results = for ((op, ind) <- reduceOperators.zipWithIndex) yield {
|
||||||
// ("op index: " + ind) |: t.reduceLeft(op) == coll.reduce(op)
|
("op index: " + ind) |: t.reduceLeft(op) == coll.reduce(op)
|
||||||
// }
|
}
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// } else "has size 0" |: true
|
} else "has size 0" |: true
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("counts must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("counts must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((pred, ind) <- countPredicates.zipWithIndex) yield {
|
val results = for ((pred, ind) <- countPredicates.zipWithIndex) yield {
|
||||||
// val tc = t.count(pred)
|
val tc = t.count(pred)
|
||||||
// val cc = coll.count(pred)
|
val cc = coll.count(pred)
|
||||||
// if (tc != cc) {
|
if (tc != cc) {
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll.toList)
|
println("and: " + coll.toList)
|
||||||
// println(tc)
|
println(tc)
|
||||||
// println(cc)
|
println(cc)
|
||||||
// }
|
}
|
||||||
// ("op index: " + ind) |: tc == cc
|
("op index: " + ind) |: tc == cc
|
||||||
// }
|
}
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("forall must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("forall must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((pred, ind) <- forallPredicates.zipWithIndex)
|
val results = for ((pred, ind) <- forallPredicates.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.forall(pred) == coll.forall(pred)
|
yield ("op index: " + ind) |: t.forall(pred) == coll.forall(pred)
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("exists must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("exists must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((pred, ind) <- existsPredicates.zipWithIndex)
|
val results = for ((pred, ind) <- existsPredicates.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.exists(pred) == coll.exists(pred)
|
yield ("op index: " + ind) |: t.exists(pred) == coll.exists(pred)
|
||||||
// results.reduceLeft(_ && _)
|
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") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((pred, ind) <- findPredicates.zipWithIndex) yield {
|
val results = for ((pred, ind) <- findPredicates.zipWithIndex) yield {
|
||||||
// val ft = t.find(pred)
|
val ft = t.find(pred)
|
||||||
// val fcoll = coll.find(pred)
|
val fcoll = coll.find(pred)
|
||||||
// ("op index: " + ind) |: ((ft == None && fcoll == None) || (ft != None && fcoll != None))
|
("op index: " + ind) |: ((ft == None && fcoll == None) || (ft != None && fcoll != None))
|
||||||
// }
|
}
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("mappings must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("mappings must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((f, ind) <- mapFunctions.zipWithIndex)
|
val results = for ((f, ind) <- mapFunctions.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.map(f) == coll.map(f)
|
yield ("op index: " + ind) |: t.map(f) == coll.map(f)
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("collects must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("collects must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield {
|
val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield {
|
||||||
// val ps = t.collect(f)
|
val ps = t.collect(f)
|
||||||
// val pp = coll.collect(f)
|
val pp = coll.collect(f)
|
||||||
// if (ps != pp) {
|
if (ps != pp) {
|
||||||
// println(t)
|
println(t)
|
||||||
// println(coll)
|
println(coll)
|
||||||
// println("partially mapped to: ")
|
println("partially mapped to: ")
|
||||||
// println(ps)
|
println(ps)
|
||||||
// println(pp)
|
println(pp)
|
||||||
// }
|
}
|
||||||
// ("op index: " + ind) |: ps == pp
|
("op index: " + ind) |: ps == pp
|
||||||
// }
|
}
|
||||||
// results.reduceLeft(_ && _)
|
results.reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("flatMaps must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("flatMaps must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((f, ind) <- flatMapFunctions.zipWithIndex)
|
(for ((f, ind) <- flatMapFunctions.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.flatMap(f) == coll.flatMap(f)).reduceLeft(_ && _)
|
yield ("op index: " + ind) |: t.flatMap(f) == coll.flatMap(f)).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("filters must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("filters must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((p, ind) <- filterPredicates.zipWithIndex)
|
(for ((p, ind) <- filterPredicates.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.filter(p) == coll.filter(p)).reduceLeft(_ && _)
|
yield ("op index: " + ind) |: t.filter(p) == coll.filter(p)).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((p, ind) <- filterNotPredicates.zipWithIndex)
|
(for ((p, ind) <- filterNotPredicates.zipWithIndex)
|
||||||
// yield ("op index: " + ind) |: t.filterNot(p) == coll.filterNot(p)).reduceLeft(_ && _)
|
yield ("op index: " + ind) |: t.filterNot(p) == coll.filterNot(p)).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((p, ind) <- partitionPredicates.zipWithIndex) yield {
|
(for ((p, ind) <- partitionPredicates.zipWithIndex) yield {
|
||||||
// val tpart = t.partition(p)
|
val tpart = t.partition(p)
|
||||||
// val cpart = coll.partition(p)
|
val cpart = coll.partition(p)
|
||||||
// if (tpart != cpart) {
|
if (tpart != cpart) {
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(cpart)
|
println(cpart)
|
||||||
// println(tpart)
|
println(tpart)
|
||||||
// }
|
}
|
||||||
// ("op index: " + ind) |: tpart == cpart
|
("op index: " + ind) |: tpart == cpart
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("takes must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
property("takes must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
||||||
// ("take " + n + " elements") |: t.take(n) == coll.take(n)
|
("take " + n + " elements") |: t.take(n) == coll.take(n)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("drops must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
property("drops must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
||||||
// ("drop " + n + " elements") |: t.drop(n) == coll.drop(n)
|
("drop " + n + " elements") |: t.drop(n) == coll.drop(n)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("slices must be equal") = forAll(collectionPairsWith2Indices)
|
property("slices must be equal") = forAll(collectionPairsWith2Indices)
|
||||||
// { case (t, coll, fr, slicelength) =>
|
{ case (t, coll, fr, slicelength) =>
|
||||||
// val from = if (fr < 0) 0 else fr
|
val from = if (fr < 0) 0 else fr
|
||||||
// val until = if (from + slicelength > t.size) t.size else from + slicelength
|
val until = if (from + slicelength > t.size) t.size else from + slicelength
|
||||||
// val tsl = t.slice(from, until)
|
val tsl = t.slice(from, until)
|
||||||
// val collsl = coll.slice(from, until)
|
val collsl = coll.slice(from, until)
|
||||||
// if (tsl != collsl) {
|
if (tsl != collsl) {
|
||||||
// println("---------------------- " + from + ", " + until)
|
println("---------------------- " + from + ", " + until)
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(tsl)
|
println(tsl)
|
||||||
// println(collsl)
|
println(collsl)
|
||||||
// println("as list: " + collsl.toList)
|
println("as list: " + collsl.toList)
|
||||||
// println(tsl.asInstanceOf[Seq[T]].sameElements(collsl))
|
println(tsl.asInstanceOf[Seq[T]].sameElements(collsl))
|
||||||
// println(collsl.iterator.hasNext)
|
println(collsl.iterator.hasNext)
|
||||||
// println(collsl.iterator.next)
|
println(collsl.iterator.next)
|
||||||
// println(collsl.iterator.hasNext)
|
println(collsl.iterator.hasNext)
|
||||||
// println(collsl.iterator.next)
|
println(collsl.iterator.next)
|
||||||
// println(collsl.iterator.hasNext)
|
println(collsl.iterator.hasNext)
|
||||||
// println(collsl.iterator.next)
|
println(collsl.iterator.next)
|
||||||
// println(collsl.iterator.hasNext)
|
println(collsl.iterator.hasNext)
|
||||||
// }
|
}
|
||||||
// ("slice from " + from + " until " + until) |: tsl == collsl
|
("slice from " + from + " until " + until) |: tsl == collsl
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("splits must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
property("splits must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) =>
|
||||||
// val tspl = t.splitAt(n)
|
val tspl = t.splitAt(n)
|
||||||
// val cspl = coll.splitAt(n)
|
val cspl = coll.splitAt(n)
|
||||||
// if (tspl != cspl) {
|
if (tspl != cspl) {
|
||||||
// println("at: " + n)
|
println("at: " + n)
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(tspl)
|
println(tspl)
|
||||||
// println(cspl)
|
println(cspl)
|
||||||
// }
|
}
|
||||||
// ("splitAt " + n) |: tspl == cspl
|
("splitAt " + n) |: tspl == cspl
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("takeWhiles must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("takeWhiles must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((pred, ind) <- takeWhilePredicates.zipWithIndex)
|
(for ((pred, ind) <- takeWhilePredicates.zipWithIndex)
|
||||||
// yield ("operator " + ind) |: t.takeWhile(pred) == coll.takeWhile(pred)).reduceLeft(_ && _)
|
yield ("operator " + ind) |: t.takeWhile(pred) == coll.takeWhile(pred)).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("spans must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("spans must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((pred, ind) <- spanPredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- spanPredicates.zipWithIndex) yield {
|
||||||
// val tsp = t.span(pred)
|
val tsp = t.span(pred)
|
||||||
// val csp = coll.span(pred)
|
val csp = coll.span(pred)
|
||||||
// if (tsp != csp) {
|
if (tsp != csp) {
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(tsp)
|
println(tsp)
|
||||||
// println(csp)
|
println(csp)
|
||||||
// }
|
}
|
||||||
// ("operator " + ind) |: tsp == csp
|
("operator " + ind) |: tsp == csp
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("dropWhiles must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("dropWhiles must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for ((pred, ind) <- dropWhilePredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- dropWhilePredicates.zipWithIndex) yield {
|
||||||
// ("operator " + ind) |: t.dropWhile(pred) == coll.dropWhile(pred)
|
("operator " + ind) |: t.dropWhile(pred) == coll.dropWhile(pred)
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("folds must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) =>
|
property("folds must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// (for (((first, op), ind) <- foldArguments.zipWithIndex)
|
(for (((first, op), ind) <- foldArguments.zipWithIndex)
|
||||||
// yield ("operator " + ind) |: t.foldLeft(first)(op) == coll.fold(first)(op)).reduceLeft(_ && _)
|
yield ("operator " + ind) |: t.foldLeft(first)(op) == coll.fold(first)(op)).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) =>
|
property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) =>
|
||||||
// val toadd = colltoadd
|
val toadd = colltoadd
|
||||||
// val tr = t ++ toadd
|
val tr = t ++ toadd
|
||||||
// val cr = coll ++ fromTraversable(toadd).iterator
|
val cr = coll ++ fromTraversable(toadd).iterator
|
||||||
// if (!tr.toList.iterator.sameElements(cr.iterator)) {
|
if (!tr.toList.iterator.sameElements(cr.iterator)) {
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll.iterator.toList)
|
println("and: " + coll.iterator.toList)
|
||||||
// println("adding: " + toadd)
|
println("adding: " + toadd)
|
||||||
// println(tr.toList)
|
println(tr.toList)
|
||||||
// println(cr.iterator.toList)
|
println(cr.iterator.toList)
|
||||||
// }
|
}
|
||||||
// ("adding " |: tr == cr) &&
|
("adding " |: tr == cr) &&
|
||||||
// (for ((trav, ind) <- (addAllTraversables).zipWithIndex) yield {
|
(for ((trav, ind) <- (addAllTraversables).zipWithIndex) yield {
|
||||||
// val tadded = t ++ trav
|
val tadded = t ++ trav
|
||||||
// val cadded = coll ++ fromTraversable(trav.toList)
|
val cadded = coll ++ fromTraversable(trav.toList)
|
||||||
// if (tadded != cadded) {
|
if (tadded != cadded) {
|
||||||
// println("----------------------")
|
println("----------------------")
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll.iterator.toList)
|
println("and: " + coll.iterator.toList)
|
||||||
// println("adding: " + trav)
|
println("adding: " + trav)
|
||||||
// println(tadded.toList)
|
println(tadded.toList)
|
||||||
// println(cadded.iterator.toList)
|
println(cadded.iterator.toList)
|
||||||
// }
|
}
|
||||||
// ("traversable " + ind) |: (tadded) == (cadded)
|
("traversable " + ind) |: (tadded) == (cadded)
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) =>
|
||||||
// val tarr = newArray(t.size)
|
val tarr = newArray(t.size)
|
||||||
// val collarr = newArray(coll.size)
|
val collarr = newArray(coll.size)
|
||||||
// t.copyToArray(tarr, 0, t.size)
|
t.copyToArray(tarr, 0, t.size)
|
||||||
// coll.copyToArray(collarr, 0, coll.size)
|
coll.copyToArray(collarr, 0, coll.size)
|
||||||
// if (tarr.toSeq != collarr.toSeq) {
|
if (tarr.toSeq != collarr.toSeq) {
|
||||||
// println("from: " + t)
|
println("from: " + t)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(tarr.toSeq)
|
println(tarr.toSeq)
|
||||||
// println(collarr.toSeq)
|
println(collarr.toSeq)
|
||||||
// }
|
}
|
||||||
// tarr.toSeq == collarr.toSeq
|
tarr.toSeq == collarr.toSeq
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,202 +63,202 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe
|
||||||
coll.patch(updateStart, coll, howMany)
|
coll.patch(updateStart, coll, howMany)
|
||||||
}
|
}
|
||||||
|
|
||||||
// property("segmentLengths must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
property("segmentLengths must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
||||||
// (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield {
|
||||||
// val slen = s.segmentLength(pred, if (len < 0) 0 else len)
|
val slen = s.segmentLength(pred, if (len < 0) 0 else len)
|
||||||
// val clen = coll.segmentLength(pred, len)
|
val clen = coll.segmentLength(pred, len)
|
||||||
// if (slen != clen) {
|
if (slen != clen) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(slen)
|
println(slen)
|
||||||
// println(clen)
|
println(clen)
|
||||||
// }
|
}
|
||||||
// ("operator " + ind) |: slen == clen
|
("operator " + ind) |: slen == clen
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("prefixLengths must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
property("prefixLengths must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
||||||
// (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield {
|
||||||
// ("operator " + ind) |: s.prefixLength(pred) == coll.prefixLength(pred)
|
("operator " + ind) |: s.prefixLength(pred) == coll.prefixLength(pred)
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("indexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
property("indexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
||||||
// (for ((pred, ind) <- indexWherePredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- indexWherePredicates.zipWithIndex) yield {
|
||||||
// val sind = s.indexWhere(pred, len)
|
val sind = s.indexWhere(pred, len)
|
||||||
// val cind = coll.indexWhere(pred, len)
|
val cind = coll.indexWhere(pred, len)
|
||||||
// if (sind != cind) {
|
if (sind != cind) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println("at: " + len)
|
println("at: " + len)
|
||||||
// println(sind)
|
println(sind)
|
||||||
// println(cind)
|
println(cind)
|
||||||
// }
|
}
|
||||||
// ("operator " + ind) |: sind == cind
|
("operator " + ind) |: sind == cind
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("lastIndexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
property("lastIndexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
||||||
// (for ((pred, ind) <- lastIndexWherePredicates.zipWithIndex) yield {
|
(for ((pred, ind) <- lastIndexWherePredicates.zipWithIndex) yield {
|
||||||
// val end = if (len >= s.size) s.size - 1 else len
|
val end = if (len >= s.size) s.size - 1 else len
|
||||||
// val sind = s.lastIndexWhere(pred, end)
|
val sind = s.lastIndexWhere(pred, end)
|
||||||
// val cind = coll.lastIndexWhere(pred, end)
|
val cind = coll.lastIndexWhere(pred, end)
|
||||||
// ("operator " + ind) |: sind == cind
|
("operator " + ind) |: sind == cind
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
||||||
// (s.length == 0 && s.getClass == classOf[collection.immutable.Range]) ||
|
(s.length == 0 && s.getClass == classOf[collection.immutable.Range]) ||
|
||||||
// {
|
{
|
||||||
// val sr = s.reverse
|
val sr = s.reverse
|
||||||
// val cr = coll.reverse
|
val cr = coll.reverse
|
||||||
// if (sr != cr) {
|
if (sr != cr) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(sr)
|
println(sr)
|
||||||
// println(cr)
|
println(cr)
|
||||||
// }
|
}
|
||||||
// sr == cr
|
sr == cr
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("reverseMaps must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
property("reverseMaps must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
||||||
// (for ((f, ind) <- reverseMapFunctions.zipWithIndex) yield {
|
(for ((f, ind) <- reverseMapFunctions.zipWithIndex) yield {
|
||||||
// ("operator " + ind) |: s.reverseMap(f) == coll.reverseMap(f)
|
("operator " + ind) |: s.reverseMap(f) == coll.reverseMap(f)
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("sameElements must be equal") = forAll(collectionPairsWithModifiedWithLengths) {
|
property("sameElements must be equal") = forAll(collectionPairsWithModifiedWithLengths) {
|
||||||
// case (s, coll, collmodif, len) =>
|
case (s, coll, collmodif, len) =>
|
||||||
// val pos = if (len < 0) 0 else len
|
val pos = if (len < 0) 0 else len
|
||||||
// val scm = s.sameElements(collmodif)
|
val scm = s.sameElements(collmodif)
|
||||||
// val ccm = coll.sameElements(collmodif)
|
val ccm = coll.sameElements(collmodif)
|
||||||
// if (scm != ccm) {
|
if (scm != ccm) {
|
||||||
// println("Comparing: " + s)
|
println("Comparing: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println("with: " + collmodif)
|
println("with: " + collmodif)
|
||||||
// println(scm)
|
println(scm)
|
||||||
// println(ccm)
|
println(ccm)
|
||||||
// }
|
}
|
||||||
// ("Nil" |: s.sameElements(Nil) == coll.sameElements(Nil)) &&
|
("Nil" |: s.sameElements(Nil) == coll.sameElements(Nil)) &&
|
||||||
// ("toList" |: s.sameElements(s.toList) == coll.sameElements(coll.toList)) &&
|
("toList" |: s.sameElements(s.toList) == coll.sameElements(coll.toList)) &&
|
||||||
// ("identity" |: s.sameElements(s.map(e => e)) == coll.sameElements(coll.map(e => e))) &&
|
("identity" |: s.sameElements(s.map(e => e)) == coll.sameElements(coll.map(e => e))) &&
|
||||||
// ("vice-versa" |: s.sameElements(coll) == coll.sameElements(s)) &&
|
("vice-versa" |: s.sameElements(coll) == coll.sameElements(s)) &&
|
||||||
// ("equal" |: s.sameElements(coll)) &&
|
("equal" |: s.sameElements(coll)) &&
|
||||||
// ("modified" |: scm == ccm) &&
|
("modified" |: scm == ccm) &&
|
||||||
// (for ((it, ind) <- sameElementsSeqs.zipWithIndex) yield {
|
(for ((it, ind) <- sameElementsSeqs.zipWithIndex) yield {
|
||||||
// val sres = s.sameElements(it)
|
val sres = s.sameElements(it)
|
||||||
// val pres = coll.sameElements(it)
|
val pres = coll.sameElements(it)
|
||||||
// if (sres != pres) {
|
if (sres != pres) {
|
||||||
// println("Comparing: " + s)
|
println("Comparing: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println("with: " + it)
|
println("with: " + it)
|
||||||
// println(sres)
|
println(sres)
|
||||||
// println(pres)
|
println(pres)
|
||||||
// }
|
}
|
||||||
// ("collection " + ind) |: sres == pres
|
("collection " + ind) |: sres == pres
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("startsWiths must be equal") = forAll(collectionPairsWithModifiedWithLengths) {
|
property("startsWiths must be equal") = forAll(collectionPairsWithModifiedWithLengths) {
|
||||||
// case (s, coll, collmodif, len) =>
|
case (s, coll, collmodif, len) =>
|
||||||
// val pos = if (len < 0) 0 else len
|
val pos = if (len < 0) 0 else len
|
||||||
// ("start with self" |: s.startsWith(s) == coll.startsWith(coll)) &&
|
("start with self" |: s.startsWith(s) == coll.startsWith(coll)) &&
|
||||||
// ("tails correspond" |: (s.length == 0 || s.startsWith(s.tail, 1) == coll.startsWith(coll.tail, 1))) &&
|
("tails correspond" |: (s.length == 0 || s.startsWith(s.tail, 1) == coll.startsWith(coll.tail, 1))) &&
|
||||||
// ("with each other" |: coll.startsWith(s)) &&
|
("with each other" |: coll.startsWith(s)) &&
|
||||||
// ("modified" |: s.startsWith(collmodif) == coll.startsWith(collmodif)) &&
|
("modified" |: s.startsWith(collmodif) == coll.startsWith(collmodif)) &&
|
||||||
// ("modified2" |: s.startsWith(collmodif, pos) == coll.startsWith(collmodif, pos)) &&
|
("modified2" |: s.startsWith(collmodif, pos) == coll.startsWith(collmodif, pos)) &&
|
||||||
// (for (sq <- startEndSeqs) yield {
|
(for (sq <- startEndSeqs) yield {
|
||||||
// val ss = s.startsWith(sq, pos)
|
val ss = s.startsWith(sq, pos)
|
||||||
// val cs = coll.startsWith(fromSeq(sq), pos)
|
val cs = coll.startsWith(fromSeq(sq), pos)
|
||||||
// if (ss != cs) {
|
if (ss != cs) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println("test seq: " + sq)
|
println("test seq: " + sq)
|
||||||
// println("from pos: " + pos)
|
println("from pos: " + pos)
|
||||||
// println(ss)
|
println(ss)
|
||||||
// println(cs)
|
println(cs)
|
||||||
// println(coll.iterator.psplit(pos, coll.length - pos)(1).toList)
|
println(coll.iterator.psplit(pos, coll.length - pos)(1).toList)
|
||||||
// }
|
}
|
||||||
// ("seq " + sq) |: ss == cs
|
("seq " + sq) |: ss == cs
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("endsWiths must be equal") = forAll(collectionPairsWithModified) {
|
property("endsWiths must be equal") = forAll(collectionPairsWithModified) {
|
||||||
// case (s, coll, collmodif) =>
|
case (s, coll, collmodif) =>
|
||||||
// ("ends with self" |: s.endsWith(s) == coll.endsWith(s)) &&
|
("ends with self" |: s.endsWith(s) == coll.endsWith(s)) &&
|
||||||
// ("ends with tail" |: (s.length == 0 || s.endsWith(s.tail) == coll.endsWith(coll.tail))) &&
|
("ends with tail" |: (s.length == 0 || s.endsWith(s.tail) == coll.endsWith(coll.tail))) &&
|
||||||
// ("with each other" |: coll.endsWith(s)) &&
|
("with each other" |: coll.endsWith(s)) &&
|
||||||
// ("modified" |: s.startsWith(collmodif) == coll.endsWith(collmodif)) &&
|
("modified" |: s.startsWith(collmodif) == coll.endsWith(collmodif)) &&
|
||||||
// (for (sq <- startEndSeqs) yield {
|
(for (sq <- startEndSeqs) yield {
|
||||||
// val sew = s.endsWith(sq)
|
val sew = s.endsWith(sq)
|
||||||
// val cew = coll.endsWith(fromSeq(sq))
|
val cew = coll.endsWith(fromSeq(sq))
|
||||||
// if (sew != cew) {
|
if (sew != cew) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(sew)
|
println(sew)
|
||||||
// println(cew)
|
println(cew)
|
||||||
// }
|
}
|
||||||
// ("seq " + sq) |: sew == cew
|
("seq " + sq) |: sew == cew
|
||||||
// }).reduceLeft(_ && _)
|
}).reduceLeft(_ && _)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("unions must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) =>
|
property("unions must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) =>
|
||||||
// ("modified" |: s.union(collmodif.seq) == coll.union(collmodif)) &&
|
("modified" |: s.union(collmodif.seq) == coll.union(collmodif)) &&
|
||||||
// ("empty" |: s.union(Nil) == coll.union(fromSeq(Nil)))
|
("empty" |: s.union(Nil) == coll.union(fromSeq(Nil)))
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (!isCheckingViews) property("patches must be equal") = forAll(collectionTripletsWith2Indices) {
|
if (!isCheckingViews) property("patches must be equal") = forAll(collectionTripletsWith2Indices) {
|
||||||
// case (s, coll, pat, from, repl) =>
|
case (s, coll, pat, from, repl) =>
|
||||||
// ("with seq" |: s.patch(from, pat, repl) == coll.patch(from, pat, repl)) &&
|
("with seq" |: s.patch(from, pat, repl) == coll.patch(from, pat, repl)) &&
|
||||||
// ("with par" |: s.patch(from, pat, repl) == coll.patch(from, fromSeq(pat), repl)) &&
|
("with par" |: s.patch(from, pat, repl) == coll.patch(from, fromSeq(pat), repl)) &&
|
||||||
// ("with empty" |: s.patch(from, Nil, repl) == coll.patch(from, fromSeq(Nil), repl)) &&
|
("with empty" |: s.patch(from, Nil, repl) == coll.patch(from, fromSeq(Nil), repl)) &&
|
||||||
// ("with one" |: (s.length == 0 || s.patch(from, List(s(0)), 1) == coll.patch(from, fromSeq(List(coll(0))), 1)))
|
("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") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
||||||
// val pos = if (len >= s.length) s.length - 1 else len
|
val pos = if (len >= s.length) s.length - 1 else len
|
||||||
// if (s.length > 0) {
|
if (s.length > 0) {
|
||||||
// val supd = s.updated(pos, s(0))
|
val supd = s.updated(pos, s(0))
|
||||||
// val cupd = coll.updated(pos, coll(0))
|
val cupd = coll.updated(pos, coll(0))
|
||||||
// if (supd != cupd) {
|
if (supd != cupd) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(supd)
|
println(supd)
|
||||||
// println(cupd)
|
println(cupd)
|
||||||
// }
|
}
|
||||||
// "from first" |: (supd == cupd)
|
"from first" |: (supd == cupd)
|
||||||
// } else "trivially" |: true
|
} else "trivially" |: true
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property("prepends must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
property("prepends must be equal") = forAll(collectionPairs) { case (s, coll) =>
|
||||||
// s.length == 0 || s(0) +: s == coll(0) +: 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") = forAll(collectionPairs) { case (s, coll) =>
|
||||||
// s.length == 0 || s :+ s(0) == coll :+ coll(0)
|
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") = forAll(collectionPairsWithLengths) { case (s, coll, len) =>
|
||||||
// val someValue = sampleValue
|
val someValue = sampleValue
|
||||||
// val sdoub = s.padTo(len * 2, someValue)
|
val sdoub = s.padTo(len * 2, someValue)
|
||||||
// val cdoub = coll.padTo(len * 2, someValue)
|
val cdoub = coll.padTo(len * 2, someValue)
|
||||||
// if (sdoub != cdoub) {
|
if (sdoub != cdoub) {
|
||||||
// println("from: " + s)
|
println("from: " + s)
|
||||||
// println("and: " + coll)
|
println("and: " + coll)
|
||||||
// println(sdoub)
|
println(sdoub)
|
||||||
// println(cdoub)
|
println(cdoub)
|
||||||
// }
|
}
|
||||||
// ("smaller" |: s.padTo(len / 2, someValue) == coll.padTo(len / 2, someValue)) &&
|
("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") = forAll(collectionPairsWithModified) { case (s, coll, modified) =>
|
||||||
// val modifcut = modified.toSeq.slice(0, modified.length)
|
val modifcut = modified.toSeq.slice(0, modified.length)
|
||||||
// ("self" |: s.corresponds(s)(_ == _) == coll.corresponds(coll)(_ == _)) &&
|
("self" |: s.corresponds(s)(_ == _) == coll.corresponds(coll)(_ == _)) &&
|
||||||
// ("modified" |: s.corresponds(modified.seq)(_ == _) == coll.corresponds(modified)(_ == _)) &&
|
("modified" |: s.corresponds(modified.seq)(_ == _) == coll.corresponds(modified)(_ == _)) &&
|
||||||
// ("modified2" |: s.corresponds(modifcut)(_ == _) == coll.corresponds(modifcut)(_ == _))
|
("modified2" |: s.corresponds(modifcut)(_ == _) == coll.corresponds(modifcut)(_ == _))
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ import scala.collection.parallel._
|
||||||
class ParCollProperties extends Properties("Parallel collections") {
|
class ParCollProperties extends Properties("Parallel collections") {
|
||||||
// parallel arrays
|
// parallel arrays
|
||||||
include(mutable.IntParallelArrayCheck)
|
include(mutable.IntParallelArrayCheck)
|
||||||
|
|
||||||
|
// parallel ranges
|
||||||
|
include(immutable.ParallelRangeCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
object Dependency {
|
||||||
|
val v = 1
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
import org.scalacheck._
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
object Test extends Properties("Nothing") {
|
||||||
|
val d = Dependency.v
|
||||||
|
}
|
Loading…
Reference in New Issue