932 |
|
} catch (java.io.NotSerializableException acceptable) {} |
933 |
|
} |
934 |
|
|
935 |
+ |
public void testReplaceAllIsNotStructuralModification() { |
936 |
+ |
Collection c = impl.emptyCollection(); |
937 |
+ |
if (!(c instanceof List)) |
938 |
+ |
return; |
939 |
+ |
List list = (List) c; |
940 |
+ |
ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
941 |
+ |
for (int n = rnd.nextInt(2, 10); n--> 0; ) |
942 |
+ |
list.add(impl.makeElement(rnd.nextInt())); |
943 |
+ |
ArrayList copy = new ArrayList(list); |
944 |
+ |
int size = list.size(), half = size / 2; |
945 |
+ |
Iterator it = list.iterator(); |
946 |
+ |
for (int i = 0; i < half; i++) |
947 |
+ |
assertEquals(it.next(), copy.get(i)); |
948 |
+ |
list.replaceAll(n -> n); |
949 |
+ |
// ConcurrentModificationException must not be thrown here. |
950 |
+ |
for (int i = half; i < size; i++) |
951 |
+ |
assertEquals(it.next(), copy.get(i)); |
952 |
+ |
} |
953 |
+ |
|
954 |
|
// public void testCollection8DebugFail() { |
955 |
|
// fail(impl.klazz().getSimpleName()); |
956 |
|
// } |