49 |
|
impl); |
50 |
|
} |
51 |
|
|
52 |
+ |
Object bomb() { |
53 |
+ |
return new Object() { |
54 |
+ |
public boolean equals(Object x) { throw new AssertionError(); } |
55 |
+ |
public int hashCode() { throw new AssertionError(); } |
56 |
+ |
}; |
57 |
+ |
} |
58 |
+ |
|
59 |
|
/** Checks properties of empty collections. */ |
60 |
|
public void testEmptyMeansEmpty() { |
61 |
|
Collection c = impl.emptyCollection(); |
88 |
|
c.iterator().forEachRemaining(alwaysThrows); |
89 |
|
c.spliterator().forEachRemaining(alwaysThrows); |
90 |
|
assertFalse(c.spliterator().tryAdvance(alwaysThrows)); |
91 |
< |
if (Queue.class.isAssignableFrom(impl.klazz())) { |
91 |
> |
if (c.spliterator().hasCharacteristics(Spliterator.SIZED)) |
92 |
> |
assertEquals(0, c.spliterator().estimateSize()); |
93 |
> |
assertFalse(c.contains(bomb())); |
94 |
> |
assertFalse(c.remove(bomb())); |
95 |
> |
if (c instanceof Queue) { |
96 |
|
Queue q = (Queue) c; |
97 |
|
assertNull(q.peek()); |
98 |
|
assertNull(q.poll()); |
99 |
|
} |
100 |
< |
if (Deque.class.isAssignableFrom(impl.klazz())) { |
100 |
> |
if (c instanceof Deque) { |
101 |
|
Deque d = (Deque) c; |
102 |
|
assertNull(d.peekFirst()); |
103 |
|
assertNull(d.peekLast()); |
104 |
|
assertNull(d.pollFirst()); |
105 |
|
assertNull(d.pollLast()); |
106 |
|
assertIteratorExhausted(d.descendingIterator()); |
107 |
+ |
d.descendingIterator().forEachRemaining(alwaysThrows); |
108 |
+ |
assertFalse(d.removeFirstOccurrence(bomb())); |
109 |
+ |
assertFalse(d.removeLastOccurrence(bomb())); |
110 |
|
} |
111 |
|
} |
112 |
|
|
196 |
|
} |
197 |
|
}; |
198 |
|
try { |
199 |
+ |
assertFalse(survivors.contains(null)); |
200 |
|
try { |
201 |
|
boolean modified = c.removeIf(randomPredicate); |
202 |
|
if (!modified) { |
218 |
|
System.err.printf("n=%d%n", n); |
219 |
|
System.err.printf("accepts=%s%n", accepts); |
220 |
|
System.err.printf("rejects=%s%n", rejects); |
221 |
< |
System.err.println(survivors); |
221 |
> |
System.err.printf("survivors=%s%n", survivors); |
222 |
|
System.err.printf("threw=%s%n", threwAt.get()); |
223 |
|
throw ex; |
224 |
|
} |