diff options
author | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
commit | b6778be91900b8161e705dc2598ef7af86842b0b (patch) | |
tree | d15e8ec18a37eec212f50f1ace27714d7e7d4d34 /test/files/scalacheck | |
parent | ac6c76f26d884a94d0c9ff54f055d3f9ab750bac (diff) | |
download | scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.gz scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.bz2 scala-b6778be91900b8161e705dc2598ef7af86842b0b.zip |
Begone t1737...
Diffstat (limited to 'test/files/scalacheck')
23 files changed, 207 insertions, 207 deletions
diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala index 0651b90b2e..a7e50877a7 100644 --- a/test/files/scalacheck/CheckEither.scala +++ b/test/files/scalacheck/CheckEither.scala @@ -9,7 +9,7 @@ import org.scalacheck.ConsoleReporter.testStatsEx import Function.tupled object CheckEither extends Properties("Either") { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = + implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n) @@ -20,7 +20,7 @@ object CheckEither extends Properties("Either") { case Left(a) => e.swap.right.get == a case Right(b) => e.swap.left.get == b }) - + val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight) object CheckLeftProjection { @@ -36,7 +36,7 @@ object CheckEither extends Properties("Either") { val prop_exists = forAll((e: Either[Int, Int]) => e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0)) - + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) Left(n).left.flatMap(f(_)) == f(n)}) @@ -116,7 +116,7 @@ object CheckEither extends Properties("Either") { } val prop_Either_left = forAll((n: Int) => Left(n).left.get == n) - + val prop_Either_right = forAll((n: Int) => Right(n).right.get == n) val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match { @@ -129,12 +129,12 @@ object CheckEither extends Properties("Either") { case Right(ee) => e.joinRight == ee }) - val prop_Either_reduce = forAll((e: Either[Int, Int]) => + val prop_Either_reduce = forAll((e: Either[Int, Int]) => e.merge == (e match { case Left(a) => a case Right(a) => a })) - + /** Hard to believe I'm "fixing" a test to reflect B before A ... */ val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) => Either.cond(c, a, b) == (if(c) Right(a) else Left(b))) @@ -169,19 +169,19 @@ object CheckEither extends Properties("Either") { ("Right.prop_seq", CheckRightProjection.prop_seq), ("Right.prop_option", CheckRightProjection.prop_option), ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), + ("prop_Either_right", prop_Either_right), ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_reduce", prop_Either_reduce), + ("prop_Either_joinRight", prop_Either_joinRight), + ("prop_Either_reduce", prop_Either_reduce), ("prop_Either_cond", prop_Either_cond) ) - + for ((label, prop) <- tests) { property(label) = prop } - + import org.scalacheck.{ Test => STest } - + def runTests() = { STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) } diff --git a/test/files/scalacheck/HashTrieSplit.scala b/test/files/scalacheck/HashTrieSplit.scala index e959a3d535..908c878f54 100644 --- a/test/files/scalacheck/HashTrieSplit.scala +++ b/test/files/scalacheck/HashTrieSplit.scala @@ -14,7 +14,7 @@ object Test { def main(args: Array[String]) { doesSplitOk } - + def doesSplitOk = { val sz = 2000 var ht = new parallel.immutable.ParHashMap[Int, Int] diff --git a/test/files/scalacheck/Unrolled.scala b/test/files/scalacheck/Unrolled.scala index 34604b8667..8067a44501 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.scala b/test/files/scalacheck/array.scala index 03c0217180..f262bc6320 100644 --- a/test/files/scalacheck/array.scala +++ b/test/files/scalacheck/array.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/list.scala b/test/files/scalacheck/list.scala index 5f6de95237..4e1cf1fc80 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 4a74b91da8..5c997962ba 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 fe851114be..4711e21c34 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 864dad2425..5007c4598b 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 255c04498e..a01c8c7dbe 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 db2b1ea01e..680f6e1d28 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 9805e2644f..d2a8fa7c22 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/ParallelHashMapCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala index 9299a201a1..0152b1b435 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 8b41908a26..a0a6d1ae5e 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 bbec52dc92..3a2893f48a 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 ac3493e56c..fbacb9f45c 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(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 53e56e9700..05237bace8 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 = for ((k, v) <- coll) yield (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 372d6b9fbd..3c6a35d8f1 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 3f8a8ad4f5..dd897412ae 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 56f7832fed..4211abbd16 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 a2b6cef96d..e4bb588fa7 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 103b5e2993..cc0382303a 100644 --- a/test/files/scalacheck/parallel-collections/pc.scala +++ b/test/files/scalacheck/parallel-collections/pc.scala @@ -9,25 +9,25 @@ 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 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 60fe63c207..a783805e46 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/substringTests.scala b/test/files/scalacheck/substringTests.scala index 76260b9dd2..a48356e1fa 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 ) |