From f2ecbd04691b1914e2f77c60afc2b296aa6826ae Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Thu, 9 Dec 2010 10:08:20 +0000 Subject: Array combiners implementation changed from arr... Array combiners implementation changed from array buffers to doubling unrolled buffers to avoid excessive copying. Still evaluating the benefits of this. No review. --- .../parallel-collections/IntOperators.scala | 3 +- .../parallel-collections/Operators.scala | 2 +- .../ParallelHashMapCheck.scala | 34 ++++++++--------- .../ParallelHashSetCheck.scala | 44 +++++++++++----------- .../ParallelIterableCheck.scala | 16 ++++++++ 5 files changed, 58 insertions(+), 41 deletions(-) (limited to 'test/files/scalacheck') diff --git a/test/files/scalacheck/parallel-collections/IntOperators.scala b/test/files/scalacheck/parallel-collections/IntOperators.scala index 690ee34cca..24330d7670 100644 --- a/test/files/scalacheck/parallel-collections/IntOperators.scala +++ b/test/files/scalacheck/parallel-collections/IntOperators.scala @@ -49,7 +49,8 @@ trait IntOperators extends Operators[Int] { def foldArguments = List( (0, _ + _), (1, _ * _), - (Int.MinValue, math.max(_, _)) + (Int.MinValue, math.max(_, _)), + (Int.MaxValue, math.min(_, _)) ) def addAllTraversables = List( List[Int](), diff --git a/test/files/scalacheck/parallel-collections/Operators.scala b/test/files/scalacheck/parallel-collections/Operators.scala index 538cc23325..b4321cf805 100644 --- a/test/files/scalacheck/parallel-collections/Operators.scala +++ b/test/files/scalacheck/parallel-collections/Operators.scala @@ -32,4 +32,4 @@ trait SeqOperators[T] extends Operators[T] { def reverseMapFunctions: List[T => T] def sameElementsSeqs: List[Seq[T]] def startEndSeqs: List[Seq[T]] -} \ No newline at end of file +} diff --git a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala index 061bb08d9b..9299a201a1 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala @@ -64,23 +64,23 @@ with PairValues[Int, Int] } 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 { - println("Does not contain original element: " + (k, v)) - false - } - }).foldLeft(true)(_ && _) - - - if (invs.isEmpty) containsall - else { - println("Invariants broken:\n" + invs.mkString("\n")) - false - } + // 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 { + // println("Does not contain original element: " + (k, v)) + // false + // } + // }).foldLeft(true)(_ && _) + + + // if (invs.isEmpty) containsall + // else { + // println("Invariants broken:\n" + invs.mkString("\n")) + // false + // } case _ => true } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala index be70a7c7a3..8b41908a26 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala @@ -56,28 +56,28 @@ with IntValues } override def checkDataStructureInvariants(orig: Traversable[Int], ds: AnyRef) = ds match { - case pm: ParHashSet[t] => - // 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 { - println("Does not contain original element: " + elem) - println(pm.hashTableContents.table.find(_ == elem)) - println(pm.hashTableContents.table.indexOf(elem)) - false - } - }).foldLeft(true)(_ && _) - - - if (invs.isEmpty) { - if (!containsall) println(pm.debugInformation) - containsall - } else { - println("Invariants broken:\n" + invs.mkString("\n")) - false - } + // 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 { + // println("Does not contain original element: " + elem) + // println(pm.hashTableContents.table.find(_ == elem)) + // println(pm.hashTableContents.table.indexOf(elem)) + // false + // } + // }).foldLeft(true)(_ && _) + + + // if (invs.isEmpty) { + // if (!containsall) println(pm.debugInformation) + // containsall + // } else { + // println("Invariants broken:\n" + invs.mkString("\n")) + // false + // } case _ => true } diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala index 8b5d72ea01..0dcd877ecb 100644 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala @@ -398,6 +398,22 @@ 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 { + val tscan = t.scanLeft(first)(op) + val cscan = coll.scan(first)(op) + if (tscan != cscan || cscan != tscan) { + println("from: " + t) + println("and: " + coll) + println("scans are: ") + println(tscan) + println(cscan) + } + ("operator " + ind) |: tscan == cscan && cscan == tscan + }).reduceLeft(_ && _) + } + } -- cgit v1.2.3