Skip to content

Commit 6715521

Browse files
committed
Restore tests transforming maps to iterables
1 parent bc33f14 commit 6715521

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

core/src/main/scala/scala/collection/parallel/mutable/ParHashMap.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
177177
buckets(pos) = new UnrolledBuffer[DefaultEntry[K, V]]()
178178
}
179179
// add to bucket
180-
buckets(pos) += new DefaultEntry[K, V](elem._1, elem._2)
180+
buckets(pos) += new DefaultEntry(elem._1, elem._2)
181181
this
182182
}
183183

@@ -202,9 +202,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
202202
var i = 0
203203
while (i < ParHashMapCombiner.numblocks) {
204204
if (buckets(i) ne null) {
205-
for (elem <- buckets(i)) {
206-
table.insertEntry(elem)
207-
}
205+
for (elem <- buckets(i)) table.insertEntry(elem)
208206
}
209207
i += 1
210208
}

scalacheck/src/test/scala/ParallelIterableCheck.scala

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col
7474
val am1: Map[Any, Any] = m1.asInstanceOf[Map[Any, Any]]
7575
val am2: ParMap[Any, Any] = m2.asInstanceOf[ParMap[Any, Any]]
7676
am1.forall { case (k, v) => am2.get(k).contains(v) } && am2.forall { case (k, v) => am1.get(k).contains(v) }
77-
case (i1: Set[T], i2: ParSet[T]) =>
78-
i1.forall(i2) && i2.forall(i1)
79-
case _ => t1.iterator.sameElements(t2) && t2.sameElements(t1)
77+
case _ =>
78+
val s1 = t1.toSet
79+
val s2 = t2.toSet
80+
s1.forall(s2) && s2.forall(s1)
8081
}
8182

8283
def printDebugInfo[A, CC[X] <: ParIterable[X], C <: ParIterable[A], S <: Iterable[A] with IterableOps[A, Iterable, S]](coll: ParIterableLike[A, CC, C, S]): Unit = {
@@ -361,13 +362,6 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col
361362
}).reduceLeft(_ && _)
362363
}
363364

364-
}
365-
366-
/**
367-
* Properties for collections whose elements are single values (as opposed to pairs of values)
368-
*/
369-
trait SimpleValuesCheck[T] { this: ParallelIterableCheck[T] =>
370-
371365
property("mappings must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) =>
372366
val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield {
373367
val ms = t.map(f)

scalacheck/src/test/scala/ParallelMapCheck1.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ abstract class ParallelMapCheck[K, V](collname: String) extends ParallelIterable
3030
(iterable.to(Map), parmap, seq)
3131
}
3232

33-
// The following tests have been copied from `SimpleValuesCheck`, and adapted to test
33+
// The following tests have been copied from `ParIterableCheck`, and adapted to test
3434
// overloads of the methods that return Map and ParMap collections
35-
property("mappings must be equal") = forAll/*NoShrink*/(collectionPairs) { case (t, coll) =>
36-
val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield {
35+
property("mappings returning maps must be equal") = forAll/*NoShrink*/(collectionPairs) { case (t, coll) =>
36+
val results = for ((f, ind) <- mapFunctions.zipWithIndex.take(5)) yield {
3737
val ms: Map[K, V] = t.map(f)
3838
val mp: ParMap[K, V] = coll.map(f)
3939
val invs = checkDataStructureInvariants(ms, mp)
@@ -53,7 +53,7 @@ abstract class ParallelMapCheck[K, V](collname: String) extends ParallelIterable
5353
results.reduceLeft(_ && _)
5454
}
5555

56-
property("collects must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) =>
56+
property("collects returning maps must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) =>
5757
val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield {
5858
val ps: Map[K, V] = t.collect(f)
5959
val pp: ParMap[K, V] = coll.collect(f)
@@ -69,12 +69,12 @@ abstract class ParallelMapCheck[K, V](collname: String) extends ParallelIterable
6969
results.reduceLeft(_ && _)
7070
}
7171

72-
property("flatMaps must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) =>
72+
property("flatMaps returning maps must be equal") = forAllNoShrink(collectionPairs) { case (t, coll) =>
7373
(for ((f, ind) <- flatMapFunctions.zipWithIndex)
7474
yield ("op index: " + ind) |: areEqual(t.flatMap(f), coll.flatMap(f))).reduceLeft(_ && _)
7575
}
7676

77-
property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) =>
77+
property("++s returning maps must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) =>
7878
try {
7979
val toadd = colltoadd
8080
val tr: Map[K, V] = t ++ toadd.iterator

scalacheck/src/test/scala/ParallelSeqCheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.collection._
1010
import scala.collection.parallel._
1111

1212
abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableCheck[T](collName)
13-
with SeqOperators[T] with SimpleValuesCheck[T] {
13+
with SeqOperators[T] {
1414

1515
type CollType <: collection.parallel.ParSeq[T]
1616

scalacheck/src/test/scala/ParallelSetCheck.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import org.scalacheck.Properties
99
import scala.collection._
1010
import scala.collection.parallel._
1111

12-
abstract class ParallelSetCheck[T](collname: String) extends ParallelIterableCheck[T](collname)
13-
with SimpleValuesCheck[T] {
12+
abstract class ParallelSetCheck[T](collname: String) extends ParallelIterableCheck[T](collname) {
1413

1514
type CollType <: ParSet[T]
1615

0 commit comments

Comments
 (0)