diff options
Diffstat (limited to 'test/files')
10 files changed, 0 insertions, 1164 deletions
diff --git a/test/files/scalacheck/parallel-collections/IntOperators.scala b/test/files/scalacheck/parallel-collections/IntOperators.scala deleted file mode 100644 index e330bec985..0000000000 --- a/test/files/scalacheck/parallel-collections/IntOperators.scala +++ /dev/null @@ -1,109 +0,0 @@ -package scala.collection.parallel.ops - - -import scala.collection.parallel._ - - -trait IntOperators extends Operators[Int] { - def reduceOperators = List(_ + _, _ * _, Math.min(_, _), Math.max(_, _)) - def countPredicates = List(_ >= 0, _ < 0, _ < 50, _ < 500, _ < 5000, _ < 50000, _ % 2 == 0, _ == 99) - def forallPredicates = List(_ >= 0, _ < 0, _ % 2 == 0, _ != 55, _ != 505, _ != 5005) - def existsPredicates = List(_ >= 0, _ < 0, _ % 2 == 0, _ == 55, _ == 505, _ == 5005) - def findPredicates = List(_ >= 0, _ % 2 == 0, _ < 0, _ == 50, _ == 500, _ == 5000) - def mapFunctions = List(-_) - def partialMapFunctions = List({case x => -x}, { case 0 => -1; case x if x > 0 => x + 1}) - def flatMapFunctions = List( - (n: Int) => if (n < 0) List() else if (n % 2 == 0) List(1, 2, 3) else List(4, 5, 6), - (n: Int) => List[Int](), - (n: Int) => if (n == 0) List(1, 2, 3, 4, 5) else if (n < 0) List(1, 2, 3) else List() - ) - def filterPredicates = List( - _ % 2 == 0, _ % 3 == 0, n => n > 50 && n < 100, _ >= 0, _ < 0, _ == 99, - _ > 500, _ > 5000, _ > 50000) - def filterNotPredicates = filterPredicates - def partitionPredicates = filterPredicates - def takeWhilePredicates = List( - _ != 50, _ != 500, _ != 5000, _ != 50000, _ % 2 == 0, _ % 3 == 1, _ % 47 != 0, - _ < 100, _ < 1000, _ < 10000, _ < 0, - _ < -100, _ < -1000, _ > -200, _ > -50, - n => -90 < n && n < -10, - n => 50 < n && n < 550, - n => 5000 < n && n < 7500) - def dropWhilePredicates = takeWhilePredicates - def spanPredicates = takeWhilePredicates - def foldArguments = List( - (0, _ + _), - (1, _ * _), - (Int.MinValue, Math.max(_, _)) - ) - def addAllTraversables = List( - List[Int](), - List(1), - List(1, 2), - List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), - Array.fill(1000)(1).toSeq - ) - def newArray(sz: Int) = new Array[Int](sz) -} - - -trait IntSeqOperators extends IntOperators with SeqOperators[Int] { - def segmentLengthPredicates = List( - _ % 2 == 0, _ > 0, _ >= 0, _ < 0, _ <= 0, _ > -5000, _ > 5000, _ % 541 != 0, _ < -50, _ > 500, - n => -90 < n && n < -10, n => 500 < n && n < 1500 - ) - def indexWherePredicates = List( - _ % 2 == 0, _ % 11 == 0, _ % 123 == 0, _ % 901 == 0, - _ > 0, _ >= 0, _ < 0, _ <= 0, - _ > 50, _ > 500, _ > 5000, - _ < -10, _ < -100, _ < -1000, - n => n > 50 && n < 100, - n => n * n > 1000000 && n % 111 == 0 - ) - def lastIndexWherePredicates = List( - _ % 2 == 0, _ % 17 == 0, _ % 314 == 0, _ % 1017 == 0, - _ > 0, _ >= 0, _ < 0, _ <= 0, - _ > 50, _ > 500, _ > 5000, - _ < -20, _ < -200, _ < -2000, - _ == 0, - n => n > -40 && n < 40, - n => n > -80 && n < -10, - n => n > 110 && n < 150 - ) - def reverseMapFunctions = List(-_, n => n * n, _ + 1) - def sameElementsSeqs = List( - List[Int](), - List(1), - List(1, 2, 3, 4, 5, 6, 7, 8, 9), - Array.fill(150)(1).toSeq, - Array.fill(1000)(1).toSeq - ) - def startEndSeqs = List( - Nil, - List(1), - List(1, 2, 3, 4, 5), - List(0, 1, 2, 3, 4, 5), - 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/IntValues.scala b/test/files/scalacheck/parallel-collections/IntValues.scala deleted file mode 100644 index b9263a2bbc..0000000000 --- a/test/files/scalacheck/parallel-collections/IntValues.scala +++ /dev/null @@ -1,26 +0,0 @@ -package scala.collection.parallel.ops - - - - - -import org.scalacheck._ -import org.scalacheck.Gen -import org.scalacheck.Gen._ -import org.scalacheck.Prop._ -import org.scalacheck.Properties -import org.scalacheck.Arbitrary._ - - - - -trait IntValues { - def values = Seq( - arbitrary[Int], - arbitrary[Int] suchThat (_ >= 0), - arbitrary[Int] suchThat (_ < 0), - choose(0, 0), - choose(0, 10), - choose(0, 100) - ) -} diff --git a/test/files/scalacheck/parallel-collections/Operators.scala b/test/files/scalacheck/parallel-collections/Operators.scala deleted file mode 100644 index 538cc23325..0000000000 --- a/test/files/scalacheck/parallel-collections/Operators.scala +++ /dev/null @@ -1,35 +0,0 @@ -package scala.collection.parallel - - - - -trait Operators[T] { - def reduceOperators: List[(T, T) => T] - def countPredicates: List[T => Boolean] - def forallPredicates: List[T => Boolean] - def existsPredicates: List[T => Boolean] - def findPredicates: List[T => Boolean] - def mapFunctions: List[T => T] - def partialMapFunctions: List[PartialFunction[T, T]] - def flatMapFunctions: List[T => Traversable[T]] - def filterPredicates: List[T => Boolean] - def filterNotPredicates: List[T => Boolean] - def partitionPredicates: List[T => Boolean] - def takeWhilePredicates: List[T => Boolean] - def dropWhilePredicates: List[T => Boolean] - def spanPredicates: List[T => Boolean] - def foldArguments: List[(T, (T, T) => T)] - def addAllTraversables: List[Traversable[T]] - def newArray(sz: Int): Array[T] -} - - - -trait SeqOperators[T] extends Operators[T] { - def segmentLengthPredicates: List[T => Boolean] - def indexWherePredicates: List[T => Boolean] - def lastIndexWherePredicates: List[T => Boolean] - 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/ParallelArrayCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala deleted file mode 100644 index 9169890e98..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala +++ /dev/null @@ -1,67 +0,0 @@ -package scala.collection.parallel -package mutable - - - -import org.scalacheck._ -import org.scalacheck.Gen -import org.scalacheck.Gen._ -import org.scalacheck.Prop._ -import org.scalacheck.Properties -import org.scalacheck.Arbitrary._ - -import scala.collection._ -import scala.collection.parallel.ops._ - - -abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("ParallelArray[" + tp + "]") { - ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) - ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - - type CollType = ParArray[T] - - def isCheckingViews = false - - def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = sized { sz => - val a = new mutable.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 ParArray[T](a.size) - var i = 0 - for (elem <- a.toList) { - pa(i) = elem - i += 1 - } - 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 => - (-sz until 0).toArray.toSeq - }) -} - - - - - - - - - - diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala b/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala deleted file mode 100644 index db2b1ea01e..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala +++ /dev/null @@ -1,112 +0,0 @@ -// package test.scala.collection.parallel.mutable - -// import org.scalatest.FunSuite -// import collection.parallel.mutable.ParallelArray - -// /** -// * Notes: -// */ -// class ParallelArrayTest extends FunSuite { - -// test("create new parallel array with a bad initial capacity"){ -// intercept[IllegalArgumentException]{ -// new ParallelArray(-5) -// } - -// /** -// * this currently passes, but do we want it to? -// * does it have meaning to have an empty parallel array? -// */ -// new ParallelArray(0) -// () -// } - -// test("compare identical ParallelArrays"){ -// assert(new ParallelArray(5) === new ParallelArray(5)) -// assert(ParallelArray(1,2,3,4,5) === ParallelArray(1,2,3,4,5)) -// } - -// /** -// * this test needs attention. how is equality defined on ParallelArrays? -// * Well, the same way it is for normal collections, I guess. For normal arrays its reference equality. -// * I do not think it should be that way in the case of ParallelArray-s. I'll check this with Martin. -// */ -// test("compare non-identical ParallelArrays"){ -// assert(ParallelArray(1,2,3,4,5) != ParallelArray(1,2,3,4), -// "compared PA's that I expect to not be identical, but they were!") -// } - -// test("creation via PA object [String]"){ -// val paFromApply: ParallelArray[String] = ParallelArray("x", "1", "true", "etrijwejiorwer") -// val paFromHandoff: ParallelArray[String] = ParallelArray.handoff(Array("x", "1", "true", "etrijwejiorwer")) -// val paFromCopy: ParallelArray[String] = ParallelArray.createFromCopy(Array("x", "1", "true", "etrijwejiorwer")) -// assert( paFromApply === paFromCopy ) -// assert( paFromApply === paFromCopy ) -// } - -// // // handoffs dont work for primitive types... -// // test("creation via PA object [Boolean]"){ -// // val paFromApply: ParallelArray[Boolean] = ParallelArray(true, false, true, false) -// // val paFromCopy: ParallelArray[Boolean] = ParallelArray.createFromCopy(Array(true, false, true, false)) -// // assert( paFromApply === paFromCopy ) -// // } -// // -// // // handoffs dont work for primitive types... -// // test("creation via PA object [Int]"){ -// // val paFromApply: ParallelArray[Int] = ParallelArray(1, 2, 4, 3) -// // val paFromCopy: ParallelArray[Int] = ParallelArray.createFromCopy(Array(1, 2, 4, 3)) -// // assert( paFromApply === paFromCopy ) -// // } - -// /** -// * This fails because handoff is really doing a copy. -// * TODO: look at handoff -// */ -// test("Handoff Is Really A Handoff"){ -// val arrayToHandOff = Array("a", "x", "y", "z") -// val paFromHandoff: ParallelArray[String] = ParallelArray.handoff(arrayToHandOff) -// arrayToHandOff(0) = "w" -// assert(paFromHandoff(0) === "w") -// } - -// test("simple reduce"){ -// assert( ParallelArray(1,2,3,4,5).reduce(_+_) === 15 ) -// } - -// test("simple count"){ -// assert( ParallelArray[Int]().count(_ > 7) === 0 ) -// assert( ParallelArray(1,2,3).count(_ > 7) === 0 ) -// assert( ParallelArray(1,2,3).count(_ <= 3) === 3 ) -// assert( ParallelArray(1,2,3,4,5,6,7,8,9,10).count(_ > 7 ) === 3 ) -// } - -// test("simple forall"){ -// assert( ParallelArray[Int]().forall(_ > 7) === true ) -// assert( ParallelArray(1,2,3).forall(_ > 3) === false ) -// assert( ParallelArray(1,2,3).forall(_ <= 3) === true ) -// assert( ParallelArray(1,2,3,4,5,6,7,8,9,10).forall(_ > 0) === true ) -// assert( ParallelArray(1,2,3,4,5,6,7,8,9,10).forall(_ < 5) === false ) -// } - -// /** -// */ -// test("simple foreach"){ -// val buf = new java.util.concurrent.ArrayBlockingQueue[Int](10000) -// ParallelArray((1 to 10000):_*).foreach(buf add _) -// (1 to 10000).foreach(i => assert( buf contains i, "buf should have contained:" + i )) -// } - -// test("simple exists"){ -// assert( ParallelArray[Int]().exists(_ => true) === false ) -// assert( ParallelArray(1,2,3).forall(_ > 3) === false ) -// assert( ParallelArray(1,2,3,4,5,6,7,8,9,10).exists(_ > 7) === true ) -// } - -// test("simple filter"){ -// assert(ParallelArray(1,2,3,4,5).filter( _ < 4 ) === ParallelArray(1,2,3)) -// } - -// test("simple map test"){ -// assert(ParallelArray(1,2,3,4,5).map( (_:Int) * 10 ) === ParallelArray(10,20,30,40,50)) -// } -// } diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala deleted file mode 100644 index a98331dc86..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala +++ /dev/null @@ -1,122 +0,0 @@ -// package scala.collection.parallel -// package mutable - - - - - - -// import org.scalacheck._ -// import org.scalacheck.Gen -// import org.scalacheck.Gen._ -// import org.scalacheck.Prop._ -// import org.scalacheck.Properties -// import org.scalacheck.Arbitrary._ - -// import scala.collection.TraversableView -// import scala.collection.mutable.ArrayBuffer -// import scala.collection.parallel.ops._ -// import scala.collection.mutable.ArraySeq - - - -// abstract class ParallelArrayViewCheck[T](tp: String) -// 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 -// for (elem <- a) { -// pa(i) = elem -// i += 1 -// } -// 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 -// } - -// } - - -// object IntParallelArrayViewCheck extends ParallelArrayViewCheck[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 => -// (-sz until 0).toArray.toSeq -// }) -// } - - -// abstract class ParallelArrayViewComposedCheck[T](tp: String) -// 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 -// for (elem <- a) { -// pa(i) = elem -// i += 1 -// } -// val modified = (pa.view ++ a).patch(0, a, a.length).reverse -// val original = modified.take(modified.length / 2).reverse -// original -// } - -// } - - -// object IntParallelArrayViewComposedCheck extends ParallelArrayViewComposedCheck[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 => -// (-sz until 0).toArray.toSeq -// }) -// } - - - - - - - - - - - - - - - - - - diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala deleted file mode 100644 index fd323ef82c..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ /dev/null @@ -1,304 +0,0 @@ -package scala.collection.parallel - - - -import org.scalacheck._ -import org.scalacheck.Gen -import org.scalacheck.Gen._ -import org.scalacheck.Prop._ -import org.scalacheck.Properties - -import scala.collection._ -import scala.collection.parallel._ - - - - -abstract class ParallelIterableCheck[T](collName: String) extends Properties(collName) with Operators[T] { - type CollType <: ParIterable[T] with Sequentializable[T, Iterable[T]] - - def values: Seq[Gen[T]] - def instances(valgens: Seq[Gen[T]]): Gen[Traversable[T]] - def fromTraversable(t: Traversable[T]): CollType - def isCheckingViews: Boolean - - 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); - updStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { - val modif = inst.toSeq.patch(updStart, inst.toSeq, howMany) - (inst, fromTraversable(inst), modif) - } - - 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 { - ("op index: " + ind) |: t.reduceLeft(op) == coll.reduce(op) - } - 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) - val cc = coll.count(pred) - if (tc != cc) { - println("from: " + t) - println("and: " + coll.toList) - println(tc) - println(cc) - } - ("op index: " + ind) |: tc == cc - } - 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) - val fcoll = coll.find(pred) - ("op index: " + ind) |: ((ft == None && fcoll == None) || (ft != None && fcoll != None)) - } - results.reduceLeft(_ && _) - } - - property("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(_ && _) - } - - property("collects must be equal") = forAll(collectionPairs) { case (t, coll) => - val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield { - val ps = t.collect(f) - val pp = coll.collect(f) - if (ps != pp) { - println(t) - println(coll) - println("partially mapped to: ") - println(ps) - println(pp) - } - ("op index: " + ind) |: ps == pp - } - results.reduceLeft(_ && _) - } - - property("flatMaps must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((f, ind) <- flatMapFunctions.zipWithIndex) - yield ("op index: " + ind) |: t.flatMap(f) == coll.flatMap(f)).reduceLeft(_ && _) - } - - property("filters must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((p, ind) <- filterPredicates.zipWithIndex) - yield ("op index: " + ind) |: t.filter(p) == coll.filter(p)).reduceLeft(_ && _) - } - - 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(_ && _) - } - - if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((p, ind) <- partitionPredicates.zipWithIndex) yield { - val tpart = t.partition(p) - val cpart = coll.partition(p) - if (tpart != cpart) { - println("from: " + t) - println("and: " + coll) - println(cpart) - println(tpart) - } - ("op index: " + ind) |: tpart == cpart - }).reduceLeft(_ && _) - } - - property("takes must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => - ("take " + n + " elements") |: t.take(n) == coll.take(n) - } - - property("drops must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => - ("drop " + n + " elements") |: t.drop(n) == coll.drop(n) - } - - property("slices must be equal") = forAll(collectionPairsWith2Indices) - { case (t, coll, fr, slicelength) => - val from = if (fr < 0) 0 else fr - val until = if (from + slicelength > t.size) t.size else from + slicelength - val tsl = t.slice(from, until) - val collsl = coll.slice(from, until) - if (tsl != collsl) { - println("---------------------- " + from + ", " + until) - println("from: " + t) - println("and: " + coll) - println(tsl) - println(collsl) - println("as list: " + collsl.toList) - println(tsl.asInstanceOf[Seq[T]].sameElements(collsl)) - println(collsl.iterator.hasNext) - println(collsl.iterator.next) - println(collsl.iterator.hasNext) - println(collsl.iterator.next) - println(collsl.iterator.hasNext) - println(collsl.iterator.next) - println(collsl.iterator.hasNext) - } - ("slice from " + from + " until " + until) |: tsl == collsl - } - - property("splits must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => - val tspl = t.splitAt(n) - val cspl = coll.splitAt(n) - if (tspl != cspl) { - println("at: " + n) - println("from: " + t) - println("and: " + coll) - println(tspl) - println(cspl) - } - ("splitAt " + n) |: tspl == cspl - } - - property("takeWhiles must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((pred, ind) <- takeWhilePredicates.zipWithIndex) - yield ("operator " + ind) |: t.takeWhile(pred) == coll.takeWhile(pred)).reduceLeft(_ && _) - } - - property("spans must be equal") = forAll(collectionPairs) { case (t, coll) => - (for ((pred, ind) <- spanPredicates.zipWithIndex) yield { - val tsp = t.span(pred) - val csp = coll.span(pred) - if (tsp != csp) { - println("from: " + t) - println("and: " + coll) - println(tsp) - println(csp) - } - ("operator " + ind) |: tsp == csp - }).reduceLeft(_ && _) - } - - 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 ("operator " + ind) |: t.foldLeft(first)(op) == coll.fold(first)(op)).reduceLeft(_ && _) - } - - property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) => - val toadd = colltoadd - val tr = t ++ toadd - val cr = coll ++ fromTraversable(toadd).iterator - if (!tr.toList.iterator.sameElements(cr.iterator)) { - println("from: " + t) - println("and: " + coll.iterator.toList) - println("adding: " + toadd) - println(tr.toList) - println(cr.iterator.toList) - } - ("adding " |: tr == cr) && - (for ((trav, ind) <- (addAllTraversables).zipWithIndex) yield { - val tadded = t ++ trav - val cadded = coll ++ fromTraversable(trav.toList) - if (tadded != cadded) { - println("----------------------") - println("from: " + t) - println("and: " + coll.iterator.toList) - println("adding: " + trav) - println(tadded.toList) - println(cadded.iterator.toList) - } - ("traversable " + ind) |: (tadded) == (cadded) - }).reduceLeft(_ && _) - } - - property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) => - val tarr = newArray(t.size) - val collarr = newArray(coll.size) - t.copyToArray(tarr, 0, t.size) - coll.copyToArray(collarr, 0, coll.size) - if (tarr.toSeq != collarr.toSeq) { - println("from: " + t) - println("and: " + coll) - println(tarr.toSeq) - println(collarr.toSeq) - } - tarr.toSeq == collarr.toSeq - } - -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala deleted file mode 100644 index 91296a2030..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala +++ /dev/null @@ -1,67 +0,0 @@ -package scala.collection.parallel -package immutable - - - - -import org.scalacheck._ -import org.scalacheck.Gen -import org.scalacheck.Gen._ -import org.scalacheck.Prop._ -import org.scalacheck.Properties -import org.scalacheck.Arbitrary._ - -import scala.collection._ -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 isCheckingViews = false - - def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start => - sized { end => - sized { step => - new Range(start, end, if (step != 0) step else 1) - } - } - } - - def fromSeq(a: Seq[Int]) = a match { - case r: Range => new ParRange(r.start, r.end, r.step, false) - case _ => - val pa = new parallel.mutable.ParArray[Int](a.length) - 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 deleted file mode 100644 index d56d06abbb..0000000000 --- a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala +++ /dev/null @@ -1,302 +0,0 @@ -package scala.collection.parallel - - - -import org.scalacheck._ -import org.scalacheck.Gen -import org.scalacheck.Gen._ -import org.scalacheck.Prop._ -import org.scalacheck.Properties - -import scala.collection._ -import scala.collection.parallel._ - - - - - -abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableCheck[T](collName) with SeqOperators[T] { - - type CollType <: collection.parallel.ParSeq[T] with Sequentializable[T, Seq[T]] - - def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] - def fromSeq(s: Seq[T]): CollType - 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 { - val parcoll = fromSeq(inst) - 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); - 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) - val clen = coll.segmentLength(pred, len) - if (slen != clen) { - println("from: " + s) - println("and: " + coll) - println(slen) - println(clen) - } - ("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) - val cind = coll.indexWhere(pred, len) - if (sind != cind) { - println("from: " + s) - println("and: " + coll) - println("at: " + len) - println(sind) - println(cind) - } - ("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 - val sind = s.lastIndexWhere(pred, end) - val cind = coll.lastIndexWhere(pred, end) - ("operator " + ind) |: sind == cind - }).reduceLeft(_ && _) - } - - property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) => - (s.length == 0 && s.getClass == classOf[collection.immutable.Range]) || - { - val sr = s.reverse - val cr = coll.reverse - if (sr != cr) { - println("from: " + s) - println("and: " + coll) - println(sr) - println(cr) - } - 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 - val scm = s.sameElements(collmodif) - val ccm = coll.sameElements(collmodif) - if (scm != ccm) { - println("Comparing: " + s) - println("and: " + coll) - println("with: " + collmodif) - println(scm) - println(ccm) - } - ("Nil" |: s.sameElements(Nil) == coll.sameElements(Nil)) && - ("toList" |: s.sameElements(s.toList) == coll.sameElements(coll.toList)) && - ("identity" |: s.sameElements(s.map(e => e)) == coll.sameElements(coll.map(e => e))) && - ("vice-versa" |: s.sameElements(coll) == coll.sameElements(s)) && - ("equal" |: s.sameElements(coll)) && - ("modified" |: scm == ccm) && - (for ((it, ind) <- sameElementsSeqs.zipWithIndex) yield { - val sres = s.sameElements(it) - val pres = coll.sameElements(it) - if (sres != pres) { - println("Comparing: " + s) - println("and: " + coll) - println("with: " + it) - println(sres) - println(pres) - } - ("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 - ("start with self" |: s.startsWith(s) == coll.startsWith(coll)) && - ("tails correspond" |: (s.length == 0 || s.startsWith(s.tail, 1) == coll.startsWith(coll.tail, 1))) && - ("with each other" |: coll.startsWith(s)) && - ("modified" |: s.startsWith(collmodif) == coll.startsWith(collmodif)) && - ("modified2" |: s.startsWith(collmodif, pos) == coll.startsWith(collmodif, pos)) && - (for (sq <- startEndSeqs) yield { - val ss = s.startsWith(sq, pos) - val cs = coll.startsWith(fromSeq(sq), pos) - if (ss != cs) { - println("from: " + s) - println("and: " + coll) - println("test seq: " + sq) - println("from pos: " + pos) - println(ss) - println(cs) - println(coll.iterator.psplit(pos, coll.length - pos)(1).toList) - } - ("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)) && - ("ends with tail" |: (s.length == 0 || s.endsWith(s.tail) == coll.endsWith(coll.tail))) && - ("with each other" |: coll.endsWith(s)) && - ("modified" |: s.startsWith(collmodif) == coll.endsWith(collmodif)) && - (for (sq <- startEndSeqs) yield { - val sew = s.endsWith(sq) - val cew = coll.endsWith(fromSeq(sq)) - if (sew != cew) { - println("from: " + s) - println("and: " + coll) - println(sew) - println(cew) - } - ("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))) - } - -// if (!isCheckingViews) property("diffs must be equal") = forAll(collectionPairsWithSliced) { case (s, coll, collsliced) => -// val sdiffs = s.diff(s) -// val cdiffc = coll.diff(coll) -// ("self" |: sdiffs.toSet == cdiffc.toSet) -// ("sliced" |: s.diff(collsliced.seq).toSet == coll.diff(collsliced).toSet) && -// ("empty" |: s.diff(Nil).toSet == coll.diff(fromSeq(Nil)).toSet) -// } -// -// if (!isCheckingViews) property("intersections must be equal") = forAll(collectionPairsWithSliced) { case (s, coll, collsliced) => -// val sints = s.intersect(s).toSet -// val cintc = coll.intersect(coll).toSet -// ("self" |: sints == cintc) && -// ("sliced" |: s.intersect(collsliced.seq).toSet == coll.intersect(collsliced).toSet) && -// ("empty" |: s.intersect(Nil).toSet == coll.intersect(fromSeq(Nil)).toSet) -// } -// -// if (!isCheckingViews) property("removeDuplicates must be equal") = forAll(collectionPairs) { case (s, coll) => -// s.removeDuplicates.toSet == coll.removeDuplicates.toSet -// } - - 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)) && - ("with par" |: s.patch(from, pat, repl) == coll.patch(from, fromSeq(pat), repl)) && - ("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) { - val supd = s.updated(pos, s(0)) - val cupd = coll.updated(pos, coll(0)) - if (supd != cupd) { - println("from: " + s) - println("and: " + coll) - println(supd) - println(cupd) - } - "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) - val cdoub = coll.padTo(len * 2, someValue) - if (sdoub != cdoub) { - println("from: " + s) - println("and: " + coll) - println(sdoub) - println(cdoub) - } - ("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/pc.scala b/test/files/scalacheck/parallel-collections/pc.scala deleted file mode 100644 index d369faf804..0000000000 --- a/test/files/scalacheck/parallel-collections/pc.scala +++ /dev/null @@ -1,20 +0,0 @@ - - - - -import org.scalacheck._ -import scala.collection.parallel._ - - -object ParCollProperties extends Properties("Parallel collections") { - include(mutable.IntParallelArrayCheck) - include(immutable.ParallelRangeCheck) -} - - -object Test { - def main(args: Array[String]) { - val results = org.scalacheck.Test.checkProperties(ParCollProperties) - if (!results.forall(_._2.passed)) println(results) - } -} |