diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-12-09 10:08:11 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-12-09 10:08:11 +0000 |
commit | a730fb5cc6cea39a29e9ff4cd666fa8498f6adec (patch) | |
tree | a271e1b7cdd2bd044344fa7aef19d6820637b3a5 /test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala | |
parent | 4dbe72f83f7ade1517bad7444009d3d0c8a69bd5 (diff) | |
download | scala-a730fb5cc6cea39a29e9ff4cd666fa8498f6adec.tar.gz scala-a730fb5cc6cea39a29e9ff4cd666fa8498f6adec.tar.bz2 scala-a730fb5cc6cea39a29e9ff4cd666fa8498f6adec.zip |
Fixing jvm 1.5 support for parallel collections.
Special cased with thread pool executor scheduling. Fixed an ugly
concurrency bug where futures returned by a thread pool executor didn't
remove the task from the queue when cancel was called. Note to self and
others: don't cancel futures returned by thread pool executors, it might
lead to unexpected behaviour. Modified the executor to add new threads
if all the active threads are syncing, in order to avoid deadlocks.
Fixed a hidden bug in AdaptiveWorkStealingTasks, where correct behaviour
depended on the execution order of the tasks. This didn't fail before
with ForkJoinTasks, since there the execution order is well-defined.
Scalachecked 1.5 & 1.6 support.
No review.
Diffstat (limited to 'test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala')
-rw-r--r-- | test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala index e8838de3f5..8b5d72ea01 100644 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala @@ -82,6 +82,33 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col 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) + println("sz: " + t.size) + println(t) + println + println("sz: " + coll.size) + println(coll) + println("transformed to:") + println + println("size: " + tf.size) + println(tf) + println + println("size: " + cf.size) + println(cf) + println + 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 { @@ -105,10 +132,11 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col val tc = t.count(pred) val cc = coll.count(pred) if (tc != cc) { - println("from: " + t) - println("and: " + coll.toList) + println("from: " + t + " - size: " + t.size) + println("and: " + coll + " - size: " + coll.toList.size) println(tc) println(cc) + printDebugInfo(coll) } ("op index: " + ind) |: tc == cc } @@ -184,11 +212,20 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col val cf = coll.filter(p) val invs = checkDataStructureInvariants(tf, cf) if (tf != cf || cf != tf || !invs) { + printDebugInfo(coll) + println("Operator: " + ind) + println("sz: " + t.size) println(t) + println + println("sz: " + coll.size) println(coll) + println println("filtered to:") + println println(cf) + println println(tf) + println println("tf == cf - " + (tf == cf)) println("cf == tf - " + (cf == tf)) printDataStructureDebugInfo(cf) @@ -199,8 +236,12 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((p, ind) <- filterNotPredicates.zipWithIndex) - yield ("op index: " + ind) |: t.filterNot(p) == coll.filterNot(p)).reduceLeft(_ && _) + (for ((p, ind) <- filterNotPredicates.zipWithIndex) yield { + val tf = t.filterNot(p) + val cf = coll.filterNot(p) + if (tf != cf || cf != tf) printComparison(t, coll, tf, cf, ind) + ("op index: " + ind) |: tf == cf && cf == tf + }).reduceLeft(_ && _) } if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) => |