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.20 by jsr166, Sun Nov 6 22:50:32 2016 UTC vs.
Revision 1.21 by jsr166, Mon Nov 7 00:37:53 2016 UTC

# Line 365 | Line 365 | public class Collection8Test extends JSR
365  
366      /**
367       * Calling Iterator#remove() after Iterator#forEachRemaining
368 <     * should remove last element
368 >     * should (maybe) remove last element
369       */
370      public void testRemoveAfterForEachRemaining() {
371          Collection c = impl.emptyCollection();
# Line 378 | Line 378 | public class Collection8Test extends JSR
378              assertEquals(impl.makeElement(0), it.next());
379              assertTrue(it.hasNext());
380              assertEquals(impl.makeElement(1), it.next());
381 <            it.forEachRemaining(e -> {});
382 <            it.remove();
383 <            assertEquals(n - 1, c.size());
384 <            for (int i = 0; i < n - 1; i++)
385 <                assertTrue(c.contains(impl.makeElement(i)));
386 <            assertFalse(c.contains(impl.makeElement(n - 1)));
381 >            it.forEachRemaining(e -> assertTrue(c.contains(e)));
382 >            if (testImplementationDetails) {
383 >                if (c instanceof java.util.concurrent.ArrayBlockingQueue) {
384 >                    assertIteratorExhausted(it);
385 >                } else {
386 >                    it.remove();
387 >                    assertEquals(n - 1, c.size());
388 >                    for (int i = 0; i < n - 1; i++)
389 >                        assertTrue(c.contains(impl.makeElement(i)));
390 >                    assertFalse(c.contains(impl.makeElement(n - 1)));
391 >                }
392 >            }
393          }
394          if (c instanceof Deque) {
395              Deque d = (Deque) impl.emptyCollection();
# Line 394 | Line 400 | public class Collection8Test extends JSR
400              assertEquals(impl.makeElement(n - 1), it.next());
401              assertTrue(it.hasNext());
402              assertEquals(impl.makeElement(n - 2), it.next());
403 <            it.forEachRemaining(e -> {});
404 <            it.remove();
405 <            assertEquals(n - 1, d.size());
406 <            for (int i = 1; i < n; i++)
407 <                assertTrue(d.contains(impl.makeElement(i)));
408 <            assertFalse(d.contains(impl.makeElement(0)));
403 >            it.forEachRemaining(e -> assertTrue(c.contains(e)));
404 >            if (testImplementationDetails) {
405 >                it.remove();
406 >                assertEquals(n - 1, d.size());
407 >                for (int i = 1; i < n; i++)
408 >                    assertTrue(d.contains(impl.makeElement(i)));
409 >                assertFalse(d.contains(impl.makeElement(0)));
410 >            }
411          }
412      }
413  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines