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.32 by jsr166, Mon Nov 28 03:30:28 2016 UTC vs.
Revision 1.37 by jsr166, Tue Nov 29 05:23:31 2016 UTC

# Line 353 | Line 353 | public class Collection8Test extends JSR
353          ArrayList iteratedForEachRemaining = new ArrayList();
354          ArrayList tryAdvanced = new ArrayList();
355          ArrayList spliterated = new ArrayList();
356 +        ArrayList splitonced = new ArrayList();
357          ArrayList forEached = new ArrayList();
358          ArrayList streamForEached = new ArrayList();
359          ConcurrentLinkedQueue parallelStreamForEached = new ConcurrentLinkedQueue();
# Line 362 | Line 363 | public class Collection8Test extends JSR
363          for (Spliterator s = c.spliterator();
364               s.tryAdvance(tryAdvanced::add); ) {}
365          c.spliterator().forEachRemaining(spliterated::add);
366 +        {                       // trySplit returns "strict prefix"
367 +            Spliterator s1 = c.spliterator(), s2 = s1.trySplit();
368 +            if (s2 != null) s2.forEachRemaining(splitonced::add);
369 +            s1.forEachRemaining(splitonced::add);
370 +        }
371          c.forEach(forEached::add);
372          c.stream().forEach(streamForEached::add);
373          c.parallelStream().forEach(parallelStreamForEached::add);
# Line 376 | Line 382 | public class Collection8Test extends JSR
382              assertEquals(iterated, iteratedForEachRemaining);
383              assertEquals(iterated, tryAdvanced);
384              assertEquals(iterated, spliterated);
385 +            assertEquals(iterated, splitonced);
386              assertEquals(iterated, forEached);
387              assertEquals(iterated, streamForEached);
388              assertEquals(iterated, removeIfed);
# Line 384 | Line 391 | public class Collection8Test extends JSR
391              assertEquals(cset, new HashSet(iteratedForEachRemaining));
392              assertEquals(cset, new HashSet(tryAdvanced));
393              assertEquals(cset, new HashSet(spliterated));
394 +            assertEquals(cset, new HashSet(splitonced));
395              assertEquals(cset, new HashSet(forEached));
396              assertEquals(cset, new HashSet(streamForEached));
397              assertEquals(cset, new HashSet(removeIfed));
# Line 549 | Line 557 | public class Collection8Test extends JSR
557          if (!impl.isConcurrent()) return;
558          final ThreadLocalRandom rnd = ThreadLocalRandom.current();
559          final Collection c = impl.emptyCollection();
560 <        final long testDurationMillis = timeoutMillis();
560 >        final long testDurationMillis
561 >            = expensiveTests ? LONG_DELAY_MS : timeoutMillis();
562          final AtomicBoolean done = new AtomicBoolean(false);
563          final Object one = impl.makeElement(1);
564          final Object two = impl.makeElement(2);
565 +        final Consumer checkSanity = x -> assertTrue(x == one || x == two);
566 +        final Consumer<Object[]> checkArraySanity = array -> {
567 +            // assertTrue(array.length <= 2); // duplicates are permitted
568 +            for (Object x : array) assertTrue(x == one || x == two);
569 +        };
570          final Object[] emptyArray =
571              (Object[]) java.lang.reflect.Array.newInstance(one.getClass(), 0);
572          final List<Future<?>> futures;
573          final Phaser threadsStarted = new Phaser(1); // register this thread
560        final Consumer checkSanity = x -> assertTrue(x == one || x == two);
574          final Runnable[] frobbers = {
575              () -> c.forEach(checkSanity),
576              () -> c.stream().forEach(checkSanity),
# Line 573 | Line 586 | public class Collection8Test extends JSR
586                  do {} while (s.tryAdvance(checkSanity));
587              },
588              () -> { for (Object x : c) checkSanity.accept(x); },
589 <            () -> { for (Object x : c.toArray()) checkSanity.accept(x); },
590 <            () -> { for (Object x : c.toArray(emptyArray)) checkSanity.accept(x); },
589 >            () -> checkArraySanity.accept(c.toArray()),
590 >            () -> checkArraySanity.accept(c.toArray(emptyArray)),
591              () -> {
592                  assertTrue(c.add(one));
593                  assertTrue(c.contains(one));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines