Skip to content

Commit c1e9bc9

Browse files
committed
Nil.min throws UnsupportedOperationException instead of NoSuchElementException
1 parent 7b80b65 commit c1e9bc9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

core/src/main/scala/scala/collection/parallel/ParIterableLike.scala

+2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ extends IterableOnce[T @uncheckedVariance]
465465
}
466466

467467
def min[U >: T](implicit ord: Ordering[U]): T = {
468+
if (isEmpty) throw new UnsupportedOperationException("empty.min")
469+
468470
tasksupport.executeAndWaitResult(new Min(ord, splitter)).get.asInstanceOf[T]
469471
}
470472

junit/src/test/scala/scala/collection/parallel/mutable/ParArrayTest.scala

+6
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,10 @@ class ParArrayTest extends scala.collection.concurrent.ctries_old.Spec {
132132
def `simple map test`: Unit = {
133133
assert(ParArray(1,2,3,4,5).map( (_:Int) * 10 ) == ParArray(10,20,30,40,50))
134134
}
135+
136+
@Test
137+
def `empty min`: Unit = {
138+
evaluating { ParArray.empty[Int].min }.shouldProduce[UnsupportedOperationException]()
139+
}
140+
135141
}

0 commit comments

Comments
 (0)