ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/Collection8Test.java
(Generate patch)

Comparing jsr166/src/test/tck/Collection8Test.java (file contents):
Revision 1.6 by jsr166, Sat Oct 29 22:47:55 2016 UTC vs.
Revision 1.10 by jsr166, Sat Nov 5 01:27:00 2016 UTC

# Line 49 | Line 49 | public class Collection8Test extends JSR
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();
# Line 81 | Line 88 | public class Collection8Test extends JSR
88          c.iterator().forEachRemaining(alwaysThrows);
89          c.spliterator().forEachRemaining(alwaysThrows);
90          assertFalse(c.spliterator().tryAdvance(alwaysThrows));
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 (Queue.class.isAssignableFrom(impl.klazz())) {
96              Queue q = (Queue) c;
97              assertNull(q.peek());
# Line 93 | Line 104 | public class Collection8Test extends JSR
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  
# Line 182 | Line 196 | public class Collection8Test extends JSR
196              }
197          };
198          try {
199 <            boolean modified = c.removeIf(randomPredicate);
200 <            if (!modified) {
201 <                assertNull(threwAt.get());
202 <                assertEquals(n, rejects.size());
203 <                assertEquals(0, accepts.size());
204 <            }
205 <        } catch (ArithmeticException ok) {}
206 <        survivors.removeAll(accepts);
207 <        if (n - accepts.size() != c.size()) {
199 >            assertFalse(survivors.contains(null));
200 >            try {
201 >                boolean modified = c.removeIf(randomPredicate);
202 >                if (!modified) {
203 >                    assertNull(threwAt.get());
204 >                    assertEquals(n, rejects.size());
205 >                    assertEquals(0, accepts.size());
206 >                }
207 >            } catch (ArithmeticException ok) {}
208 >            survivors.removeAll(accepts);
209 >            assertEquals(n - accepts.size(), c.size());
210 >            assertTrue(c.containsAll(survivors));
211 >            assertTrue(survivors.containsAll(rejects));
212 >            for (Object x : accepts) assertFalse(c.contains(x));
213 >            if (threwAt.get() == null)
214 >                assertEquals(accepts.size() + rejects.size(), n);
215 >        } catch (Throwable ex) {
216              System.err.println(impl.klazz());
217 <            System.err.println(c);
218 <            System.err.println(accepts);
219 <            System.err.println(rejects);
220 <            System.err.println(survivors);
221 <            System.err.println(threwAt.get());
222 <        }
223 <        assertEquals(n - accepts.size(), c.size());
224 <        assertTrue(c.containsAll(survivors));
203 <        assertTrue(survivors.containsAll(rejects));
204 <        for (Object x : accepts) assertFalse(c.contains(x));
205 <        if (threwAt.get() == null)
206 <            assertEquals(accepts.size() + rejects.size(), n);
217 >            System.err.printf("c=%s%n", c);
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.printf("survivors=%s%n", survivors);
222 >            System.err.printf("threw=%s%n", threwAt.get());
223 >            throw ex;
224 >        }
225      }
226  
227      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines