diff options
author | Paul Phillips <paulp@improving.org> | 2013-09-18 00:09:46 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-09-18 07:13:38 -0700 |
commit | f4267ccd96a9143c910c66a5b0436aaa64b7c9dc (patch) | |
tree | 174861715807c23ba332f78769a9f7e1377b7f02 /test/files/scalacheck | |
parent | d45a3c8cc8e9f1d95d797d548a85abd8597f5bc7 (diff) | |
download | scala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.tar.gz scala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.tar.bz2 scala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.zip |
Cull extraneous whitespace.
One last flurry with the broom before I leave you slobs to code
in your own filth. Eliminated all the trailing whitespace I
could manage, with special prejudice reserved for the test cases
which depended on the preservation of trailing whitespace.
Was reminded I cannot figure out how to eliminate the trailing
space on the "scala> " prompt in repl transcripts. At least
reduced the number of such empty prompts by trimming transcript
code on the way in.
Routed ConsoleReporter's "printMessage" through a trailing
whitespace stripping method which might help futureproof
against the future of whitespace diseases. Deleted the up-to-40
lines of trailing whitespace found in various library files.
It seems like only yesterday we performed whitespace surgery
on the whole repo. Clearly it doesn't stick very well. I suggest
it would work better to enforce a few requirements on the way in.
Diffstat (limited to 'test/files/scalacheck')
27 files changed, 254 insertions, 254 deletions
diff --git a/test/files/scalacheck/Ctrie.scala b/test/files/scalacheck/Ctrie.scala index 736bf938bc..714f1c3b09 100644 --- a/test/files/scalacheck/Ctrie.scala +++ b/test/files/scalacheck/Ctrie.scala @@ -17,21 +17,21 @@ case class Wrap(i: Int) { /** A check mainly oriented towards checking snapshot correctness. */ object Test extends Properties("concurrent.TrieMap") { - + /* generators */ - + val sizes = choose(0, 200000) - + val threadCounts = choose(2, 16) - + val threadCountsAndSizes = for { p <- threadCounts sz <- sizes } yield (p, sz); - - + + /* helpers */ - + def inParallel[T](totalThreads: Int)(body: Int => T): Seq[T] = { val threads = for (idx <- 0 until totalThreads) yield new Thread { setName("ParThread-" + idx) @@ -44,11 +44,11 @@ object Test extends Properties("concurrent.TrieMap") { res } } - + threads foreach (_.start()) threads map (_.result) } - + def spawn[T](body: =>T): { def get: T } = { val t = new Thread { setName("SpawnThread") @@ -66,7 +66,7 @@ object Test extends Properties("concurrent.TrieMap") { } } } - + def elementRange(threadIdx: Int, totalThreads: Int, totalElems: Int): Range = { val sz = totalElems val idx = threadIdx @@ -76,7 +76,7 @@ object Test extends Properties("concurrent.TrieMap") { val end = start + elems (start until end) } - + def hasGrown[K, V](last: Map[K, V], current: Map[K, V]) = { (last.size <= current.size) && { last forall { @@ -84,7 +84,7 @@ object Test extends Properties("concurrent.TrieMap") { } } } - + object err { var buffer = new StringBuilder def println(a: AnyRef) = buffer.append(a.toString).append("\n") @@ -94,16 +94,16 @@ object Test extends Properties("concurrent.TrieMap") { clear() } } - - + + /* properties */ - + property("concurrent growing snapshots") = forAll(threadCounts, sizes) { (numThreads, numElems) => val p = 3 //numThreads val sz = 102 //numElems val ct = new TrieMap[Wrap, Int] - + // checker val checker = spawn { def check(last: Map[Wrap, Int], iterationsLeft: Int): Boolean = { @@ -115,23 +115,23 @@ object Test extends Properties("concurrent.TrieMap") { } check(ct.readOnlySnapshot(), 500) } - + // fillers inParallel(p) { idx => elementRange(idx, p, sz) foreach (i => ct.update(Wrap(i), i)) } - + // wait for checker to finish val growing = true//checker.get - + val ok = growing && ((0 until sz) forall { case i => ct.get(Wrap(i)) == Some(i) }) - + ok } - + property("update") = forAll(sizes) { (n: Int) => val ct = new TrieMap[Int, Int] @@ -140,52 +140,52 @@ object Test extends Properties("concurrent.TrieMap") { case i => ct(i) == i } } - + property("concurrent update") = forAll(threadCountsAndSizes) { case (p, sz) => val ct = new TrieMap[Wrap, Int] - + inParallel(p) { idx => for (i <- elementRange(idx, p, sz)) ct(Wrap(i)) = i } - + (0 until sz) forall { case i => ct(Wrap(i)) == i } } - - + + property("concurrent remove") = forAll(threadCounts, sizes) { (p, sz) => val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(Wrap(i)) = i - + inParallel(p) { idx => for (i <- elementRange(idx, p, sz)) ct.remove(Wrap(i)) } - + (0 until sz) forall { case i => ct.get(Wrap(i)) == None } } - - + + property("concurrent putIfAbsent") = forAll(threadCounts, sizes) { (p, sz) => val ct = new TrieMap[Wrap, Int] - + val results = inParallel(p) { idx => elementRange(idx, p, sz) find (i => ct.putIfAbsent(Wrap(i), i) != None) } - + (results forall (_ == None)) && ((0 until sz) forall { case i => ct.get(Wrap(i)) == Some(i) }) } - + } diff --git a/test/files/scalacheck/Unrolled.scala b/test/files/scalacheck/Unrolled.scala index 8067a44501..34604b8667 100644 --- a/test/files/scalacheck/Unrolled.scala +++ b/test/files/scalacheck/Unrolled.scala @@ -5,7 +5,7 @@ import Gen._ import collection.mutable.UnrolledBuffer object Test extends Properties("UnrolledBuffer") { - + property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => val u1 = new UnrolledBuffer[Int] u1 ++= l1 @@ -15,12 +15,12 @@ object Test extends Properties("UnrolledBuffer") { u1 concat u2 totalsz == u1.size } - + property("adding") = forAll { (l: List[Int]) => val u = new UnrolledBuffer[Int] u ++= l u == l } - + } diff --git a/test/files/scalacheck/array-old.scala b/test/files/scalacheck/array-old.scala index f262bc6320..03c0217180 100644 --- a/test/files/scalacheck/array-old.scala +++ b/test/files/scalacheck/array-old.scala @@ -11,7 +11,7 @@ object Test extends Properties("Array") { */ 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]]], @@ -20,7 +20,7 @@ object Test extends Properties("Array") { 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) @@ -32,6 +32,6 @@ object Test extends Properties("Array") { 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/avl.scala b/test/files/scalacheck/avl.scala index 02003bd271..4cfacaf407 100644 --- a/test/files/scalacheck/avl.scala +++ b/test/files/scalacheck/avl.scala @@ -52,7 +52,7 @@ package scala.collection.mutable { } yield { // selected mustn't be in elements already val list = makeAllBalancedTree(elements.sorted.distinct.map(_*2)) - (selected*2+1, list) + (selected*2+1, list) } def genInputDelete: org.scalacheck.Gen[(Int, List[AVLTree[Int]])] = for { @@ -63,7 +63,7 @@ package scala.collection.mutable { } yield { // selected must be in elements already val list = makeAllBalancedTree(e) - (e(selected), list) + (e(selected), list) } } @@ -76,7 +76,7 @@ package scala.collection.mutable { } def setup(invariant: AVLTree[Int] => Boolean) = forAll(genInput) { - case (selected: Int, trees: List[AVLTree[Int]]) => + case (selected: Int, trees: List[AVLTree[Int]]) => trees.map(tree => invariant(tree)).fold(true)((a, b) => a && b) } diff --git a/test/files/scalacheck/list.scala b/test/files/scalacheck/list.scala index 4e1cf1fc80..5f6de95237 100644 --- a/test/files/scalacheck/list.scala +++ b/test/files/scalacheck/list.scala @@ -12,7 +12,7 @@ object Test extends Properties("List") { 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) => + forAll { (x: Int) => val xs = List.fill(count)(x) (xs.length == count) && (xs.distinct == List(x)) } diff --git a/test/files/scalacheck/parallel-collections/IntOperators.scala b/test/files/scalacheck/parallel-collections/IntOperators.scala index 5c997962ba..4a74b91da8 100644 --- a/test/files/scalacheck/parallel-collections/IntOperators.scala +++ b/test/files/scalacheck/parallel-collections/IntOperators.scala @@ -106,7 +106,7 @@ trait IntSeqOperators extends IntOperators with SeqOperators[Int] { List(4, 5, 6, 7, 8, 9, 10), List(4, 5, 6, 7, 8, 9, 0), List(-4, -3, -2, -1) - ) + ) } diff --git a/test/files/scalacheck/parallel-collections/PairOperators.scala b/test/files/scalacheck/parallel-collections/PairOperators.scala index 4711e21c34..fe851114be 100644 --- a/test/files/scalacheck/parallel-collections/PairOperators.scala +++ b/test/files/scalacheck/parallel-collections/PairOperators.scala @@ -7,76 +7,76 @@ import scala.collection.parallel._ trait PairOperators[K, V] extends Operators[(K, V)] { def koperators: Operators[K] def voperators: Operators[V] - + private def zipPredicates(kps: List[K => Boolean], vps: List[V => Boolean]): List[((K, V)) => Boolean] = for { (kp, vp) <- koperators.countPredicates zip voperators.countPredicates } yield new Function1[(K, V), Boolean] { def apply(kv: (K, V)) = kp(kv._1) && vp(kv._2) } - + /* operators */ - + def reduceOperators = for { (kop, vop) <- koperators.reduceOperators zip voperators.reduceOperators } yield new Function2[(K, V), (K, V), (K, V)] { def apply(kv1: (K, V), kv2: (K, V)) = (kop(kv1._1, kv2._1), vop(kv1._2, kv2._2)) } - + def countPredicates = zipPredicates(koperators.countPredicates, voperators.countPredicates) - + def forallPredicates = zipPredicates(koperators.forallPredicates, voperators.forallPredicates) - + def existsPredicates = zipPredicates(koperators.existsPredicates, voperators.existsPredicates) - + def findPredicates = zipPredicates(koperators.findPredicates, voperators.findPredicates) - + def mapFunctions = for { (km, vm) <- koperators.mapFunctions zip voperators.mapFunctions } yield new Function1[(K, V), (K, V)] { def apply(kv: (K, V)) = (km(kv._1), vm(kv._2)) } - + def partialMapFunctions = for { (kpm, vpm) <- koperators.partialMapFunctions zip voperators.partialMapFunctions } yield new PartialFunction[(K, V), (K, V)] { def isDefinedAt(kv: (K, V)) = kpm.isDefinedAt(kv._1) && vpm.isDefinedAt(kv._2) def apply(kv: (K, V)) = (kpm(kv._1), vpm(kv._2)) } - + def flatMapFunctions = for { (kfm, vfm) <- koperators.flatMapFunctions zip voperators.flatMapFunctions } yield new Function1[(K, V), Traversable[(K, V)]] { def apply(kv: (K, V)) = kfm(kv._1).toIterable zip vfm(kv._2).toIterable } - + def filterPredicates = zipPredicates(koperators.filterPredicates, voperators.filterPredicates) - + def filterNotPredicates = filterPredicates - + def partitionPredicates = filterPredicates - + def takeWhilePredicates = zipPredicates(koperators.takeWhilePredicates, voperators.takeWhilePredicates) - + def dropWhilePredicates = takeWhilePredicates - + def spanPredicates = takeWhilePredicates - + def foldArguments = for { ((kinit, kop), (vinit, vop)) <- koperators.foldArguments zip voperators.foldArguments } yield ((kinit, vinit), new Function2[(K, V), (K, V), (K, V)] { def apply(kv1: (K, V), kv2: (K, V)) = (kop(kv1._1, kv2._1), vop(kv1._2, kv2._2)) }) - + def addAllTraversables = for { (kt, vt) <- koperators.addAllTraversables zip voperators.addAllTraversables } yield kt.toIterable zip vt.toIterable - + def newArray(sz: Int) = new Array[(K, V)](sz) - + def groupByFunctions = (koperators.groupByFunctions zip voperators.groupByFunctions) map { opt => { (p: (K, V)) => (opt._1(p._1), opt._2(p._2)) } } - + } diff --git a/test/files/scalacheck/parallel-collections/PairValues.scala b/test/files/scalacheck/parallel-collections/PairValues.scala index 5007c4598b..864dad2425 100644 --- a/test/files/scalacheck/parallel-collections/PairValues.scala +++ b/test/files/scalacheck/parallel-collections/PairValues.scala @@ -17,7 +17,7 @@ import org.scalacheck.Arbitrary._ trait PairValues[K, V] { def kvalues: Seq[Gen[K]] def vvalues: Seq[Gen[V]] - + def values = for { kg <- kvalues vg <- vvalues diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala index a01c8c7dbe..255c04498e 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala @@ -17,11 +17,11 @@ import scala.collection.parallel.ops._ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("ParArray[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParArray[T] - + def isCheckingViews = false - + def hasStrictOrder = true def ofSize(vals: Seq[Gen[T]], sz: Int) = { @@ -30,7 +30,7 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa for (i <- 0 until sz) a += sample(gen) a } - + def fromSeq(a: Seq[T]) = { val pa = new ParArray[T](a.size) var i = 0 @@ -40,20 +40,20 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa } pa } - + property("array mappings must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield ("op index: " + ind) |: t.map(f) == coll.map(f) results.reduceLeft(_ && _) } - + } object IntParallelArrayCheck extends ParallelArrayCheck[Int]("Int") with IntSeqOperators with IntValues { override def instances(vals: Seq[Gen[Int]]) = oneOf(super.instances(vals), sized { sz => (0 until sz).toArray.toSeq - }, sized { sz => + }, sized { sz => (-sz until 0).toArray.toSeq }) } diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala b/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala index 680f6e1d28..db2b1ea01e 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala @@ -15,7 +15,7 @@ // /** // * this currently passes, but do we want it to? -// * does it have meaning to have an empty parallel array? +// * does it have meaning to have an empty parallel array? // */ // new ParallelArray(0) // () diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala index d2a8fa7c22..9805e2644f 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala @@ -24,18 +24,18 @@ // extends ParallelSeqCheck[T]("ParallelSeqView[" + tp + ", ParallelArray[" + tp + "]]") { // // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + // type CollType = ParallelSeqView[T, ParallelArray[T], ArraySeq[T]] - + // def isCheckingViews = true - + // def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = sized { sz => // val a = new ArrayBuffer[T](sz) // val gen = vals(rnd.nextInt(vals.size)) // for (i <- 0 until sz) a += sample(gen) // a // } - + // def fromSeq(a: Seq[T]) = { // val pa = new ParallelArray[T](a.size) // var i = 0 @@ -45,13 +45,13 @@ // } // pa.view // } - + // property("forces must be equal") = forAll(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 // } - + // } @@ -68,18 +68,18 @@ // extends ParallelSeqCheck[T]("ParallelSeqView[" + tp + "], ParallelArray[" + tp + "].++.patch.reverse.take.reverse") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + // type CollType = collection.parallel.ParallelSeq[T] - + // def isCheckingViews = true - + // def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = sized { sz => // val a = new ArrayBuffer[T](sz) // val gen = vals(rnd.nextInt(vals.size)) // for (i <- 0 until sz) a += sample(gen) // a // } - + // def fromSeq(a: Seq[T]) = { // val pa = new ParallelArray[T](a.size) // var i = 0 @@ -91,7 +91,7 @@ // val original = modified.take(modified.length / 2).reverse // original // } - + // } diff --git a/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala b/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala index e141c398fd..b952704af2 100644 --- a/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala @@ -18,20 +18,20 @@ import scala.collection.parallel.ops._ abstract class ParallelConcurrentTrieMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("mutable.ParConcurrentTrieMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParTrieMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { val ct = new concurrent.TrieMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) ct += sample(gen) ct } - + def fromTraversable(t: Traversable[(K, V)]) = { val pct = new ParTrieMap[K, V] var i = 0 @@ -41,7 +41,7 @@ abstract class ParallelConcurrentTrieMapCheck[K, V](tp: String) extends Parallel } pct } - + } @@ -52,22 +52,22 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParTrieMap[k, v] => println("Mutable parallel ctrie") case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[(Int, Int)], ds: AnyRef) = ds match { // case pm: ParHashMap[k, v] if 1 == 0 => // disabled this to make tests faster // val invs = pm.brokenInvariants - + // val containsall = (for ((k, v) <- orig) yield { // if (pm.asInstanceOf[ParHashMap[Int, Int]].get(k) == Some(v)) true // else { @@ -75,8 +75,8 @@ with PairValues[Int, Int] // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) containsall // else { // println("Invariants broken:\n" + invs.mkString("\n")) @@ -84,7 +84,7 @@ with PairValues[Int, Int] // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala index 0152b1b435..9299a201a1 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("mutable.ParHashMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { val hm = new mutable.HashMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[(K, V)]) = { val phm = new ParHashMap[K, V] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K } phm } - + } @@ -51,22 +51,22 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => println("Mutable parallel hash map\n" + pm.hashTableContents.debugInformation) case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[(Int, Int)], ds: AnyRef) = ds match { // case pm: ParHashMap[k, v] if 1 == 0 => // disabled this to make tests faster // val invs = pm.brokenInvariants - + // val containsall = (for ((k, v) <- orig) yield { // if (pm.asInstanceOf[ParHashMap[Int, Int]].get(k) == Some(v)) true // else { @@ -74,8 +74,8 @@ with PairValues[Int, Int] // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) containsall // else { // println("Invariants broken:\n" + invs.mkString("\n")) @@ -83,7 +83,7 @@ with PairValues[Int, Int] // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala index a0a6d1ae5e..8b41908a26 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T]("mutable.ParHashSet[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashSet[T] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[T]], sz: Int) = { + def ofSize(vals: Seq[Gen[T]], sz: Int) = { val hm = new mutable.HashSet[T] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[T]) = { val phm = new ParHashSet[T] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } phm } - + } @@ -54,12 +54,12 @@ with IntValues case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[Int], ds: AnyRef) = ds match { // case pm: ParHashSet[t] if 1 == 0 => // // for an example of how not to write code proceed below // val invs = pm.brokenInvariants - + // val containsall = (for (elem <- orig) yield { // if (pm.asInstanceOf[ParHashSet[Int]](elem) == true) true // else { @@ -69,8 +69,8 @@ with IntValues // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) { // if (!containsall) println(pm.debugInformation) // containsall @@ -80,7 +80,7 @@ with IntValues // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala index 3a2893f48a..bbec52dc92 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("immutable.ParHashMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { var hm = new immutable.HashMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[(K, V)]) = { var phm = new ParHashMap[K, V] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K } phm } - + } @@ -51,11 +51,11 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => pm.printDebugInfo @@ -69,20 +69,20 @@ with PairValues[Int, Int] abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T]("immutable.ParHashSet[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashSet[T] - + def isCheckingViews = false - + def hasStrictOrder = false - + def ofSize(vals: Seq[Gen[T]], sz: Int) = { var hm = new immutable.HashSet[T] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[T]) = { var phm = new ParHashSet[T] var i = 0 @@ -92,14 +92,14 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } phm } - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashSet[t] => println("Parallel hash set") case _ => println("could not match data structure type: " + ds.getClass) } - + } @@ -110,7 +110,7 @@ with IntValues def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => pm.printDebugInfo diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala index e3f8778bca..26fa71d72c 100644 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala @@ -16,14 +16,14 @@ import scala.collection.parallel._ abstract class ParallelIterableCheck[T](collName: String) extends Properties(collName) with Operators[T] { type CollType <: ParIterable[T] - + def values: Seq[Gen[T]] def ofSize(vals: Seq[Gen[T]], sz: Int): Iterable[T] def fromTraversable(t: Traversable[T]): CollType def isCheckingViews: Boolean def hasStrictOrder: Boolean - - + + def instances(vals: Seq[Gen[T]]): Gen[Iterable[T]] = oneOf( sized( sz => @@ -31,46 +31,46 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ), for (sz <- choose(1000, 2000)) yield ofSize(vals, sz), for (sz <- choose(4000, 4001)) yield ofSize(vals, sz), - for (sz <- choose(10000, 10001)) yield ofSize(vals, sz) + for (sz <- choose(10000, 10001)) yield ofSize(vals, sz) ) - + // used to check if constructed collection is valid def checkDataStructureInvariants(orig: Traversable[T], cf: AnyRef) = { // can be overriden in subclasses true } - + def printDataStructureDebugInfo(cf: AnyRef) { // can be overridden in subclasses } - + val rnd = new scala.util.Random - + def sample(gen: Gen[T]): T = { var s = gen.sample while (s == None) s = gen.sample s.get } - + def sampleValue: T = sample(values(rnd.nextInt(values.length))) - + def collectionPairs = for (inst <- instances(values)) yield (inst, fromTraversable(inst)) - + def collectionPairsWithLengths = for (inst <- instances(values); s <- choose(0, inst.size)) yield (inst, fromTraversable(inst), s) - + def collectionPairsWith2Indices = for ( inst <- instances(values); f <- choose(0, inst.size); s <- choose(0, inst.size)) yield (inst, fromTraversable(inst), f, s) - - def collectionTriplets = for (inst <- instances(values); + + def collectionTriplets = for (inst <- instances(values); updStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val modif = inst.toSeq.patch(updStart, inst.toSeq, howMany) (inst, fromTraversable(inst), modif) } - + def areEqual(t1: GenTraversable[T], t2: GenTraversable[T]) = if (hasStrictOrder) { t1 == t2 && t2 == t1 } else (t1, t2) match { // it is slightly delicate what `equal` means if the order is not strict @@ -81,14 +81,14 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col i1s == i2s && i2s == i1s case _ => t1 == t2 && t2 == t1 } - + def printDebugInfo(coll: ParIterableLike[_, _, _]) { println("Collection debug info: ") coll.printDebugBuffer println("Task debug info: ") println(coll.tasksupport.debugMessages.mkString("\n")) } - + def printComparison(t: Traversable[_], coll: ParIterable[_], tf: Traversable[_], cf: ParIterable[_], ind: Int) { printDebugInfo(coll) println("Operator: " + ind) @@ -108,7 +108,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col println("tf == cf - " + (tf == cf)) println("cf == tf - " + (cf == tf)) } - + property("reductions must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) => if (t.size != 0) { val results = for ((op, ind) <- reduceOperators.zipWithIndex) yield { @@ -126,7 +126,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } else "has size 0" |: true } - + property("counts must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- countPredicates.zipWithIndex) yield { val tc = t.count(pred) @@ -142,19 +142,19 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("forall must be equal") = forAll(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) => 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) => val results = for ((pred, ind) <- findPredicates.zipWithIndex) yield { val ft = t.find(pred) @@ -163,7 +163,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("mappings must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield { val ms = t.map(f) @@ -184,7 +184,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("collects must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield { val ps = t.collect(f) @@ -200,12 +200,12 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("flatMaps must be equal") = forAll(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) => (for ((p, ind) <- filterPredicates.zipWithIndex) yield { val tf = t.filter(p) @@ -234,7 +234,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tf == cf && cf == tf && invs }).reduceLeft(_ && _) } - + property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((p, ind) <- filterNotPredicates.zipWithIndex) yield { val tf = t.filterNot(p) @@ -243,7 +243,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tf == cf && cf == tf }).reduceLeft(_ && _) } - + if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((p, ind) <- partitionPredicates.zipWithIndex) yield { val tpart = t.partition(p) @@ -257,15 +257,15 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tpart == cpart }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("takes must be equal") = forAll(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) => ("drop " + n + " elements") |: t.drop(n) == coll.drop(n) } - + if (hasStrictOrder) property("slices must be equal") = forAll(collectionPairsWith2Indices) { case (t, coll, fr, slicelength) => val from = if (fr < 0) 0 else fr @@ -289,7 +289,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) => val tspl = t.splitAt(n) val cspl = coll.splitAt(n) @@ -302,7 +302,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) => (for ((pred, ind) <- takeWhilePredicates.zipWithIndex) yield { val tt = t.takeWhile(pred) @@ -317,7 +317,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tt == ct }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("spans must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((pred, ind) <- spanPredicates.zipWithIndex) yield { val tsp = t.span(pred) @@ -335,13 +335,13 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tsp == csp }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("dropWhiles must be equal") = forAll(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) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { val tres = t.foldLeft(first)(op) @@ -356,7 +356,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tres == cres }).reduceLeft(_ && _) } - + property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) => val toadd = colltoadd val tr = t ++ toadd.iterator @@ -383,7 +383,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("traversable " + ind) |: areEqual(tadded, cadded) }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) => val tarr = newArray(t.size) val collarr = newArray(coll.size) @@ -397,7 +397,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } tarr.toSeq == collarr.toSeq } - + if (hasStrictOrder) property("scans must be equal") = forAll(collectionPairs) { case (t, coll) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { @@ -413,7 +413,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tscan == cscan && cscan == tscan }).reduceLeft(_ && _) } - + property("groupBy must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((f, ind) <- groupByFunctions.zipWithIndex) yield { @@ -429,7 +429,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tgroup == cgroup && cgroup == tgroup }).reduceLeft(_ && _) } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala index b6af8f41bd..d4643e7f2c 100644 --- a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala +++ b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala @@ -16,15 +16,15 @@ 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) { 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) } ("Par contains elements of seq map" |: containsT.forall(_ == true)) && ("Par contains elements of itself" |: containsSelf.forall(_ == true)) - } - + } + } diff --git a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala index 3c6a35d8f1..372d6b9fbd 100644 --- a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala @@ -20,15 +20,15 @@ import scala.collection.parallel.ops._ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") with ops.IntSeqOperators { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = collection.parallel.ParSeq[Int] - + def hasStrictOrder = true - + def isCheckingViews = false - + def ofSize(vals: Seq[Gen[Int]], sz: Int) = unsupported - + override def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start => sized { end => sized { step => @@ -36,7 +36,7 @@ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") wi } } } - + def fromSeq(a: Seq[Int]) = a match { case r: Range => ParRange(r.start, r.end, r.step, false) case _ => @@ -44,14 +44,14 @@ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") wi for (i <- 0 until a.length) pa(i) = a(i) pa } - + override def traversable2Seq(t: Traversable[Int]): Seq[Int] = t match { case r: Range => r case _ => t.toSeq } - + def values = Seq(choose(-100, 100)) - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala index dd897412ae..3f8a8ad4f5 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala @@ -16,13 +16,13 @@ import scala.collection.parallel._ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableCheck[T](collName) with SeqOperators[T] { - + type CollType <: collection.parallel.ParSeq[T] - + def ofSize(vals: Seq[Gen[T]], sz: Int): Seq[T] def fromSeq(s: Seq[T]): CollType - + override def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = oneOf( sized( sz => @@ -31,17 +31,17 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe for (sz <- choose(1000, 2000)) yield ofSize(vals, sz) ) - + def fromTraversable(t: Traversable[T]) = fromSeq(traversable2Seq(t)) def traversable2Seq(t: Traversable[T]): Seq[T] = { if (t.isInstanceOf[Iterable[_]]) t.asInstanceOf[Iterable[T]].iterator.toList else t.toList } - + override def collectionPairs: Gen[(Seq[T], CollType)] = for (inst <- instances(values)) yield (inst, fromSeq(inst)) - + override def collectionPairsWithLengths: Gen[(Seq[T], CollType, Int)] = for (inst <- instances(values); s <- choose(0, inst.size)) yield (inst, fromSeq(inst), s); - + def collectionPairsWithModifiedWithLengths: Gen[(Seq[T], CollType, ParSeq[T], Int)] = for (inst <- instances(values); s <- choose(0, inst.size); updateStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { @@ -49,31 +49,31 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe val parcollmodif = fromSeq(modifySlightly(inst, updateStart, howMany)) (inst, parcoll, parcollmodif, s) } - + def collectionPairsWithModified: Gen[(Seq[T], CollType, ParSeq[T])] = for (inst <- instances(values); updateStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val parcoll = fromSeq(inst) val parcollmodif = fromSeq(modifySlightly(inst, updateStart, howMany)) (inst, parcoll, parcollmodif) } - + def collectionPairsWithSliced: Gen[(Seq[T], CollType, ParSeq[T])] = for (inst <- instances(values); sliceStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val parcoll = fromSeq(inst) val parcollsliced = fromSeq(inst.slice(sliceStart, sliceStart + howMany)) (inst, parcoll, parcollsliced) } - + def collectionTripletsWith2Indices: Gen[(Seq[T], CollType, Seq[T], Int, Int)] = for (inst <- instances(values); f <- choose(0, inst.size); s <- choose(0, inst.size - f); third <- instances(values); sliceStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { (inst, fromSeq(inst), inst.slice(sliceStart, sliceStart + howMany), f, s) } - + private def modifySlightly(coll: Seq[T], updateStart: Int, howMany: Int) = { coll.patch(updateStart, coll, howMany) } - + property("segmentLengths must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield { val slen = s.segmentLength(pred, if (len < 0) 0 else len) @@ -87,13 +87,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: slen == clen }).reduceLeft(_ && _) } - + property("prefixLengths must be equal") = forAll(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) => (for ((pred, ind) <- indexWherePredicates.zipWithIndex) yield { val sind = s.indexWhere(pred, len) @@ -108,7 +108,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: sind == cind }).reduceLeft(_ && _) } - + property("lastIndexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- lastIndexWherePredicates.zipWithIndex) yield { val end = if (len >= s.size) s.size - 1 else len @@ -117,7 +117,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: sind == cind }).reduceLeft(_ && _) } - + property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) => (s.length == 0 && s.getClass == classOf[collection.immutable.Range]) || { @@ -132,13 +132,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe sr == cr } } - + property("reverseMaps must be equal") = forAll(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) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len @@ -170,7 +170,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("collection " + ind) |: sres == pres }).reduceLeft(_ && _) } - + property("startsWiths must be equal") = forAll(collectionPairsWithModifiedWithLengths) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len @@ -194,7 +194,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("seq " + sq) |: ss == cs }).reduceLeft(_ && _) } - + property("endsWiths must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) => ("ends with self" |: s.endsWith(s) == coll.endsWith(s)) && @@ -213,18 +213,18 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("seq " + sq) |: sew == cew }).reduceLeft(_ && _) } - + property("unions must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) => ("modified" |: s.union(collmodif.seq) == coll.union(collmodif)) && ("empty" |: s.union(Nil) == coll.union(fromSeq(Nil))) } - + // This is failing with my views patch: array index out of bounds in the array iterator. // Couldn't see why this and only this was impacted, could use a second pair of eyes. - // + // // This was failing because some corner cases weren't added to the patch method in ParSeqLike. // Curiously, this wasn't detected before. - // + // if (!isCheckingViews) property("patches must be equal") = forAll(collectionTripletsWith2Indices) { case (s, coll, pat, from, repl) => ("with seq" |: s.patch(from, pat, repl) == coll.patch(from, pat, repl)) && @@ -232,7 +232,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("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))) } - + if (!isCheckingViews) property("updates must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => val pos = if (len >= s.length) s.length - 1 else len if (s.length > 0) { @@ -247,15 +247,15 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe "from first" |: (supd == cupd) } else "trivially" |: true } - + property("prepends must be equal") = forAll(collectionPairs) { case (s, coll) => s.length == 0 || s(0) +: s == coll(0) +: coll } - + property("appends must be equal") = forAll(collectionPairs) { case (s, coll) => s.length == 0 || s :+ s(0) == coll :+ coll(0) } - + property("padTos must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => val someValue = sampleValue val sdoub = s.padTo(len * 2, someValue) @@ -269,14 +269,14 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("smaller" |: s.padTo(len / 2, someValue) == coll.padTo(len / 2, someValue)) && ("bigger" |: sdoub == cdoub) } - + property("corresponds must be equal") = forAll(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)(_ == _)) && ("modified2" |: s.corresponds(modifcut)(_ == _) == coll.corresponds(modifcut)(_ == _)) } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala index 4211abbd16..56f7832fed 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala @@ -16,15 +16,15 @@ import scala.collection.parallel._ abstract class ParallelSetCheck[T](collname: String) extends ParallelIterableCheck[T](collname) { type CollType <: ParSet[T] - + property("gets iterated keys") = forAll(collectionPairs) { case (t, coll) => val containsT = for (elem <- t) yield (coll.contains(elem)) val containsSelf = for (elem <- coll) yield (coll.contains(elem)) ("Par contains elements of seq map" |: containsT.forall(_ == true)) && ("Par contains elements of itself" |: containsSelf.forall(_ == true)) - } - + } + } diff --git a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala index e4bb588fa7..a2b6cef96d 100644 --- a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala @@ -23,11 +23,11 @@ import immutable.VectorBuilder abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.ParallelSeqCheck[T]("ParVector[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParVector[T] - + def isCheckingViews = false - + def hasStrictOrder = true def ofSize(vals: Seq[Gen[T]], sz: Int) = { @@ -36,13 +36,13 @@ abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.Pa for (i <- 0 until sz) vb += sample(gen) vb.result } - + def fromSeq(a: Seq[T]) = { val pa = ParVector.newCombiner[T] for (elem <- a.toList) pa += elem pa.result } - + } diff --git a/test/files/scalacheck/parallel-collections/pc.scala b/test/files/scalacheck/parallel-collections/pc.scala index e6b6b4856d..c588692fd2 100644 --- a/test/files/scalacheck/parallel-collections/pc.scala +++ b/test/files/scalacheck/parallel-collections/pc.scala @@ -8,28 +8,28 @@ import scala.collection.parallel._ class ParCollProperties extends Properties("Parallel collections") { /* Collections */ - + // parallel arrays include(mutable.IntParallelArrayCheck) - + // parallel ranges include(immutable.ParallelRangeCheck) - + // parallel immutable hash maps (tries) include(immutable.IntIntParallelHashMapCheck) - + // parallel immutable hash sets (tries) include(immutable.IntParallelHashSetCheck) - + // parallel mutable hash maps (tables) include(mutable.IntIntParallelHashMapCheck) - + // parallel ctrie include(mutable.IntIntParallelConcurrentTrieMapCheck) - + // parallel mutable hash sets (tables) include(mutable.IntParallelHashSetCheck) - + // parallel vectors include(immutable.IntParallelVectorCheck) } diff --git a/test/files/scalacheck/primitive-eqeq.scala b/test/files/scalacheck/primitive-eqeq.scala index a783805e46..60fe63c207 100644 --- a/test/files/scalacheck/primitive-eqeq.scala +++ b/test/files/scalacheck/primitive-eqeq.scala @@ -4,7 +4,7 @@ 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 @@ -14,15 +14,15 @@ object Test extends Properties("==") { 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 { + + 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 (_ == _)) && + ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && + ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) ) result diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala index 72979115be..6c7c32bfdf 100644 --- a/test/files/scalacheck/range.scala +++ b/test/files/scalacheck/range.scala @@ -30,7 +30,7 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) { def myGen: Gen[Range] def genReasonableSizeRange = oneOf(genArbitraryRange, genBoundaryRange) - + def genArbitraryRange = for { start <- choose(Int.MinValue, Int.MaxValue) end <- choose(Int.MinValue, Int.MaxValue) @@ -56,7 +56,7 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) { } yield if (start < end) Range(start, end, step) else Range(start, end, -step) def genRangeByOne = oneOf(genRangeOpenByOne, genRangeClosedByOne) - + def genRangeOpenByOne = for { r <- oneOf(genSmallRange, genBoundaryRange) if (r.end.toLong - r.start.toLong).abs <= 10000000L diff --git a/test/files/scalacheck/redblacktree.scala b/test/files/scalacheck/redblacktree.scala index bc7f92aa1b..871444a4b8 100644 --- a/test/files/scalacheck/redblacktree.scala +++ b/test/files/scalacheck/redblacktree.scala @@ -205,22 +205,22 @@ package scala.collection.immutable.redblacktree { filteredTree == keysIterator(newTree).toList } } - + object TestDrop extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ - + override type ModifyParm = Int override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = drop(tree, parm) - + property("drop") = forAll(genInput) { case (tree, parm, newTree) => iterator(tree).drop(parm).toList == iterator(newTree).toList } } - + object TestTake extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ - + override type ModifyParm = Int override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = take(tree, parm) @@ -229,7 +229,7 @@ package scala.collection.immutable.redblacktree { iterator(tree).take(parm).toList == iterator(newTree).toList } } - + object TestSlice extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ @@ -239,7 +239,7 @@ package scala.collection.immutable.redblacktree { to <- choose(from, iterator(tree).size) } yield (from, to) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = slice(tree, parm._1, parm._2) - + property("slice") = forAll(genInput) { case (tree, parm, newTree) => iterator(tree).slice(parm._1, parm._2).toList == iterator(newTree).toList } diff --git a/test/files/scalacheck/substringTests.scala b/test/files/scalacheck/substringTests.scala index a48356e1fa..76260b9dd2 100644 --- a/test/files/scalacheck/substringTests.scala +++ b/test/files/scalacheck/substringTests.scala @@ -6,11 +6,11 @@ object Test extends Properties("String") { property("endsWith") = Prop.forAll((a: String, b: String) => (a+b).endsWith(b)) - property("concat") = Prop.forAll((a: String, b: String) => + property("concat") = Prop.forAll((a: String, b: String) => (a+b).length >= a.length && (a+b).length >= b.length ) - property("substring") = Prop.forAll((a: String, b: String) => + property("substring") = Prop.forAll((a: String, b: String) => (a+b).substring(a.length) == b ) diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala index 018c1b9e29..7fca3ed5e4 100644 --- a/test/files/scalacheck/treeset.scala +++ b/test/files/scalacheck/treeset.scala @@ -149,7 +149,7 @@ object Test extends Properties("TreeSet") { val result = subject.foldLeft(subject)((acc, elt) => acc - elt) result.isEmpty } - + property("ordering must not be null") = throws(TreeSet.empty[Int](null), classOf[NullPointerException]) } |