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

# Line 98 | Line 98 | public class Collection8Test extends JSR
98              assertSame(3, a[2]);
99          }
100          assertIteratorExhausted(c.iterator());
101 <        Consumer alwaysThrows = (e) -> { throw new AssertionError(); };
101 >        Consumer alwaysThrows = e -> { throw new AssertionError(); };
102          c.forEach(alwaysThrows);
103          c.iterator().forEachRemaining(alwaysThrows);
104          c.spliterator().forEachRemaining(alwaysThrows);
# Line 256 | Line 256 | public class Collection8Test extends JSR
256          ArrayList accepts = new ArrayList();
257          ArrayList rejects = new ArrayList();
258  
259 <        Predicate randomPredicate = (e) -> {
259 >        Predicate randomPredicate = e -> {
260              assertNull(threwAt.get());
261              switch (rnd.nextInt(3)) {
262              case 0: accepts.add(e); return true;
# 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  
# Line 412 | Line 420 | public class Collection8Test extends JSR
420          final Object x = impl.makeElement(1);
421          final Object y = impl.makeElement(2);
422          final ArrayList found = new ArrayList();
423 <        Consumer<Object> spy = (o) -> { found.add(o); };
423 >        Consumer<Object> spy = o -> found.add(o);
424          c.stream().forEach(spy);
425          assertTrue(found.isEmpty());
426  
# Line 446 | Line 454 | public class Collection8Test extends JSR
454              Runnable checkElt = () -> {
455                  threadsStarted.countDown();
456                  while (!done.get())
457 <                    c.stream().forEach((x) -> { assertSame(x, elt); }); };
457 >                    c.stream().forEach(x -> assertSame(x, elt)); };
458              Runnable addRemove = () -> {
459                  threadsStarted.countDown();
460                  while (!done.get()) {
# Line 470 | Line 478 | public class Collection8Test extends JSR
478          final Object x = impl.makeElement(1);
479          final Object y = impl.makeElement(2);
480          final ArrayList found = new ArrayList();
481 <        Consumer<Object> spy = (o) -> { found.add(o); };
481 >        Consumer<Object> spy = o -> found.add(o);
482          c.forEach(spy);
483          assertTrue(found.isEmpty());
484  
# Line 504 | Line 512 | public class Collection8Test extends JSR
512              Runnable checkElt = () -> {
513                  threadsStarted.countDown();
514                  while (!done.get())
515 <                    c.forEach((x) -> { assertSame(x, elt); }); };
515 >                    c.forEach(x -> assertSame(x, elt)); };
516              Runnable addRemove = () -> {
517                  threadsStarted.countDown();
518                  while (!done.get()) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines