Fixes the broken test, introduced in the view patch commit.

No review.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@24434 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
prokopec 2011-03-11 23:07:08 +00:00
parent e64aca37f1
commit a4462caac5
2 changed files with 15 additions and 10 deletions

View File

@ -262,9 +262,10 @@ self =>
} else patch_sequential(from, patch, replaced)
}
private def patch_sequential[U >: T, That](from: Int, patch: Seq[U], r: Int)(implicit bf: CanBuildFrom[Repr, U, That]): That = {
private def patch_sequential[U >: T, That](fromarg: Int, patch: Seq[U], r: Int)(implicit bf: CanBuildFrom[Repr, U, That]): That = {
val from = 0 max fromarg
val b = bf(repr)
val repl = r min (length - from)
val repl = (r min (length - from)) max 0
val pits = parallelIterator.psplit(from, repl, length - from - repl)
b ++= pits(0)
b ++= patch.iterator

View File

@ -65,7 +65,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe
}
def collectionTripletsWith2Indices: Gen[(Seq[T], CollType, Seq[T], Int, Int)] =
for (inst <- instances(values); f <- choose(0, inst.size); s <- choose(0, inst.size);
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)
}
@ -218,16 +218,20 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe
("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.
//
// 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)))
// }
// 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)) &&
("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