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.44 by jsr166, Sun Dec 18 20:47:28 2016 UTC vs.
Revision 1.45 by jsr166, Mon Dec 26 19:54:46 2016 UTC

# Line 727 | Line 727 | public class Collection8Test extends JSR
727      }
728  
729      /**
730 +     * Concurrent Spliterators, once exhausted, stay exhausted.
731 +     */
732 +    public void testStickySpliteratorExhaustion() throws Throwable {
733 +        if (!impl.isConcurrent()) return;
734 +        if (!testImplementationDetails) return;
735 +        final ThreadLocalRandom rnd = ThreadLocalRandom.current();
736 +        final Consumer alwaysThrows = e -> { throw new AssertionError(); };
737 +        final Collection c = impl.emptyCollection();
738 +        final Spliterator s = c.spliterator();
739 +        if (rnd.nextBoolean()) {
740 +            assertFalse(s.tryAdvance(alwaysThrows));
741 +        } else {
742 +            s.forEachRemaining(alwaysThrows);
743 +        }
744 +        final Object one = impl.makeElement(1);
745 +        // Spliterator should not notice added element
746 +        c.add(one);
747 +        if (rnd.nextBoolean()) {
748 +            assertFalse(s.tryAdvance(alwaysThrows));
749 +        } else {
750 +            s.forEachRemaining(alwaysThrows);
751 +        }
752 +    }
753 +
754 +    /**
755       * Motley crew of threads concurrently randomly hammer the collection.
756       */
757      public void testDetectRaces() throws Throwable {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines