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.31 by jsr166, Wed Nov 23 02:20:56 2016 UTC vs.
Revision 1.32 by jsr166, Mon Nov 28 03:30:28 2016 UTC

# Line 21 | Line 21 | import java.util.Queue;
21   import java.util.Spliterator;
22   import java.util.concurrent.BlockingDeque;
23   import java.util.concurrent.BlockingQueue;
24 + import java.util.concurrent.ConcurrentLinkedQueue;
25   import java.util.concurrent.CountDownLatch;
26   import java.util.concurrent.Executors;
27   import java.util.concurrent.ExecutorService;
# Line 353 | Line 354 | public class Collection8Test extends JSR
354          ArrayList tryAdvanced = new ArrayList();
355          ArrayList spliterated = new ArrayList();
356          ArrayList forEached = new ArrayList();
357 +        ArrayList streamForEached = new ArrayList();
358 +        ConcurrentLinkedQueue parallelStreamForEached = new ConcurrentLinkedQueue();
359          ArrayList removeIfed = new ArrayList();
360          for (Object x : c) iterated.add(x);
361          c.iterator().forEachRemaining(iteratedForEachRemaining::add);
# Line 360 | Line 363 | public class Collection8Test extends JSR
363               s.tryAdvance(tryAdvanced::add); ) {}
364          c.spliterator().forEachRemaining(spliterated::add);
365          c.forEach(forEached::add);
366 +        c.stream().forEach(streamForEached::add);
367 +        c.parallelStream().forEach(parallelStreamForEached::add);
368          c.removeIf(e -> { removeIfed.add(e); return false; });
369          boolean ordered =
370              c.spliterator().hasCharacteristics(Spliterator.ORDERED);
371          if (c instanceof List || c instanceof Deque)
372              assertTrue(ordered);
373 +        HashSet cset = new HashSet(c);
374 +        assertEquals(cset, new HashSet(parallelStreamForEached));
375          if (ordered) {
376              assertEquals(iterated, iteratedForEachRemaining);
377              assertEquals(iterated, tryAdvanced);
378              assertEquals(iterated, spliterated);
379              assertEquals(iterated, forEached);
380 +            assertEquals(iterated, streamForEached);
381              assertEquals(iterated, removeIfed);
382          } else {
375            HashSet cset = new HashSet(c);
383              assertEquals(cset, new HashSet(iterated));
384              assertEquals(cset, new HashSet(iteratedForEachRemaining));
385              assertEquals(cset, new HashSet(tryAdvanced));
386              assertEquals(cset, new HashSet(spliterated));
387              assertEquals(cset, new HashSet(forEached));
388 +            assertEquals(cset, new HashSet(streamForEached));
389              assertEquals(cset, new HashSet(removeIfed));
390          }
391          if (c instanceof Deque) {
# Line 549 | Line 557 | public class Collection8Test extends JSR
557              (Object[]) java.lang.reflect.Array.newInstance(one.getClass(), 0);
558          final List<Future<?>> futures;
559          final Phaser threadsStarted = new Phaser(1); // register this thread
560 +        final Consumer checkSanity = x -> assertTrue(x == one || x == two);
561          final Runnable[] frobbers = {
562 <            () -> c.forEach(x -> assertTrue(x == one || x == two)),
563 <            () -> c.stream().forEach(x -> assertTrue(x == one || x == two)),
562 >            () -> c.forEach(checkSanity),
563 >            () -> c.stream().forEach(checkSanity),
564 >            () -> c.parallelStream().forEach(checkSanity),
565              () -> c.spliterator().trySplit(),
566              () -> {
567                  Spliterator s = c.spliterator();
568 <                s.tryAdvance(x -> assertTrue(x == one || x == two));
568 >                s.tryAdvance(checkSanity);
569                  s.trySplit();
570              },
571              () -> {
572                  Spliterator s = c.spliterator();
573 <                do {} while (s.tryAdvance(x -> assertTrue(x == one || x == two)));
564 <            },
565 <            () -> {
566 <                for (Object x : c) assertTrue(x == one || x == two);
567 <            },
568 <            () -> {
569 <                for (Object x : c.toArray()) assertTrue(x == one || x == two);
570 <            },
571 <            () -> {
572 <                for (Object x : c.toArray(emptyArray)) assertTrue(x == one || x == two);
573 >                do {} while (s.tryAdvance(checkSanity));
574              },
575 +            () -> { for (Object x : c) checkSanity.accept(x); },
576 +            () -> { for (Object x : c.toArray()) checkSanity.accept(x); },
577 +            () -> { for (Object x : c.toArray(emptyArray)) checkSanity.accept(x); },
578              () -> {
579                  assertTrue(c.add(one));
580                  assertTrue(c.contains(one));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines