summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-06-27 13:44:52 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-06-28 09:48:16 +1000
commit1ae80e868039e4e18843ec67768002085decb763 (patch)
tree79568458bcabd26115d45a8f5e2a6a865d4c9a81 /src
parent22dac3118e97b2a4707d42ef1f47ac292a8ed385 (diff)
downloadscala-1ae80e868039e4e18843ec67768002085decb763.tar.gz
scala-1ae80e868039e4e18843ec67768002085decb763.tar.bz2
scala-1ae80e868039e4e18843ec67768002085decb763.zip
Fix ParVector#padTo
This was throwing a UnsupportedOperationError for small operations. The parallel collections test suite sets `-minSuccessfulTests 5` in test/files/scalacheck/parallel-collections/pc.scala, which is far lower thatn the default of 100, and means that we are less likely to falsify properties. This parameter seems to have been added in #2476, assuming I'm reading it correctly. Not sure of the motiviation, perhaps just to make the slowest part of the scalacheck test suite run faster? I haven't changed the paramater now, but instead have included a one element collection in generator. I also found that when the test failed, Scalacheck would try to minimize the example, but did so assuming that the elements of the tuple of test data could be independentally shrunk. This breaks the invariant that the two collections contain equal elements, and led to spurious error reports. I have disabled shrinking in all tests tests affected by this.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/parallel/immutable/package.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/library/scala/collection/parallel/immutable/package.scala b/src/library/scala/collection/parallel/immutable/package.scala
index 8fd84eaf4d..3cafdba5f7 100644
--- a/src/library/scala/collection/parallel/immutable/package.scala
+++ b/src/library/scala/collection/parallel/immutable/package.scala
@@ -20,7 +20,12 @@ package immutable {
self =>
def apply(idx: Int) = if (0 <= idx && idx < length) elem else throw new IndexOutOfBoundsException("" + idx)
- override def seq = throw new UnsupportedOperationException
+ override def seq: collection.immutable.Seq[T] = new collection.AbstractSeq[T] with collection.immutable.Seq[T] {
+ override def length: Int = self.length
+ override def apply(idx: Int): T = self.apply(idx)
+ override def iterator: Iterator[T] = Iterator.continually(elem).take(length)
+ override def par: ParSeq[T] = self
+ }
def update(idx: Int, elem: T) = throw new UnsupportedOperationException
class ParIterator(var i: Int = 0, val until: Int = length, elem: T = self.elem) extends SeqSplitter[T] {