--- jsr166/src/test/tck/Collection8Test.java 2016/11/06 22:42:10 1.19 +++ jsr166/src/test/tck/Collection8Test.java 2016/11/07 00:37:53 1.21 @@ -365,7 +365,7 @@ public class Collection8Test extends JSR /** * Calling Iterator#remove() after Iterator#forEachRemaining - * should remove last element + * should (maybe) remove last element */ public void testRemoveAfterForEachRemaining() { Collection c = impl.emptyCollection(); @@ -378,12 +378,18 @@ public class Collection8Test extends JSR assertEquals(impl.makeElement(0), it.next()); assertTrue(it.hasNext()); assertEquals(impl.makeElement(1), it.next()); - it.forEachRemaining(e -> {}); - it.remove(); - assertEquals(n - 1, c.size()); - for (int i = 0; i < n - 1; i++) - assertTrue(c.contains(impl.makeElement(i))); - assertFalse(c.contains(impl.makeElement(n - 1))); + it.forEachRemaining(e -> assertTrue(c.contains(e))); + if (testImplementationDetails) { + if (c instanceof java.util.concurrent.ArrayBlockingQueue) { + assertIteratorExhausted(it); + } else { + it.remove(); + assertEquals(n - 1, c.size()); + for (int i = 0; i < n - 1; i++) + assertTrue(c.contains(impl.makeElement(i))); + assertFalse(c.contains(impl.makeElement(n - 1))); + } + } } if (c instanceof Deque) { Deque d = (Deque) impl.emptyCollection(); @@ -394,12 +400,14 @@ public class Collection8Test extends JSR assertEquals(impl.makeElement(n - 1), it.next()); assertTrue(it.hasNext()); assertEquals(impl.makeElement(n - 2), it.next()); - it.forEachRemaining(e -> {}); - it.remove(); - assertEquals(n - 1, d.size()); - for (int i = 1; i < n; i++) - assertTrue(d.contains(impl.makeElement(i))); - assertFalse(d.contains(impl.makeElement(0))); + it.forEachRemaining(e -> assertTrue(c.contains(e))); + if (testImplementationDetails) { + it.remove(); + assertEquals(n - 1, d.size()); + for (int i = 1; i < n; i++) + assertTrue(d.contains(impl.makeElement(i))); + assertFalse(d.contains(impl.makeElement(0))); + } } } @@ -412,7 +420,7 @@ public class Collection8Test extends JSR final Object x = impl.makeElement(1); final Object y = impl.makeElement(2); final ArrayList found = new ArrayList(); - Consumer spy = o -> { found.add(o); }; + Consumer spy = o -> found.add(o); c.stream().forEach(spy); assertTrue(found.isEmpty()); @@ -446,7 +454,7 @@ public class Collection8Test extends JSR Runnable checkElt = () -> { threadsStarted.countDown(); while (!done.get()) - c.stream().forEach(x -> { assertSame(x, elt); }); }; + c.stream().forEach(x -> assertSame(x, elt)); }; Runnable addRemove = () -> { threadsStarted.countDown(); while (!done.get()) { @@ -470,7 +478,7 @@ public class Collection8Test extends JSR final Object x = impl.makeElement(1); final Object y = impl.makeElement(2); final ArrayList found = new ArrayList(); - Consumer spy = o -> { found.add(o); }; + Consumer spy = o -> found.add(o); c.forEach(spy); assertTrue(found.isEmpty()); @@ -504,7 +512,7 @@ public class Collection8Test extends JSR Runnable checkElt = () -> { threadsStarted.countDown(); while (!done.get()) - c.forEach(x -> { assertSame(x, elt); }); }; + c.forEach(x -> assertSame(x, elt)); }; Runnable addRemove = () -> { threadsStarted.countDown(); while (!done.get()) {