8329089: Empty immutable list throws the wrong exception type for remove(first | last) operations
Reviewed-by: rriggs
This commit is contained in:
parent
1131bb77ec
commit
b71acc704a
@ -258,6 +258,8 @@ class ImmutableCollections {
|
||||
@Override public void add(int index, E element) { throw uoe(); }
|
||||
@Override public boolean addAll(int index, Collection<? extends E> c) { throw uoe(); }
|
||||
@Override public E remove(int index) { throw uoe(); }
|
||||
@Override public E removeFirst() { throw uoe(); }
|
||||
@Override public E removeLast() { throw uoe(); }
|
||||
@Override public void replaceAll(UnaryOperator<E> operator) { throw uoe(); }
|
||||
@Override public E set(int index, E element) { throw uoe(); }
|
||||
@Override public void sort(Comparator<? super E> c) { throw uoe(); }
|
||||
|
@ -246,6 +246,7 @@ public class MOAT {
|
||||
testCollection(list);
|
||||
testImmutableList(list);
|
||||
testListMutatorsAlwaysThrow(list);
|
||||
testImmutableListMutatorsAlwaysThrow(list);
|
||||
if (list.size() >= 1) {
|
||||
// test subLists
|
||||
List<Integer> headList = list.subList(0, list.size() - 1);
|
||||
@ -564,6 +565,12 @@ public class MOAT {
|
||||
() -> c.addAll(0, Collections.emptyList()));
|
||||
}
|
||||
|
||||
private static void testImmutableListMutatorsAlwaysThrow(List<Integer> c) {
|
||||
THROWS(UnsupportedOperationException.class,
|
||||
c::removeFirst,
|
||||
c::removeLast);
|
||||
}
|
||||
|
||||
/**
|
||||
* As above, for an empty list.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user