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.29 by jsr166, Tue Nov 22 01:08:14 2016 UTC vs.
Revision 1.31 by jsr166, Wed Nov 23 02:20:56 2016 UTC

# Line 606 | Line 606 | public class Collection8Test extends JSR
606              assertNull(future.get(0L, MILLISECONDS));
607      }
608  
609 +    /**
610 +     * Spliterators are either IMMUTABLE or truly late-binding or, if
611 +     * concurrent, use the same "late-binding style" of returning
612 +     * elements added between creation and first use.
613 +     */
614 +    public void testLateBindingStyle() {
615 +        if (!testImplementationDetails) return;
616 +        if (impl.klazz() == ArrayList.class) return; // for jdk8
617 +        // Immutable (snapshot) spliterators are exempt
618 +        if (impl.emptyCollection().spliterator()
619 +            .hasCharacteristics(Spliterator.IMMUTABLE))
620 +            return;
621 +        final Object one = impl.makeElement(1);
622 +        {
623 +            final Collection c = impl.emptyCollection();
624 +            final Spliterator split = c.spliterator();
625 +            c.add(one);
626 +            assertTrue(split.tryAdvance(e -> { assertSame(e, one); }));
627 +            assertFalse(split.tryAdvance(e -> { throw new AssertionError(); }));
628 +            assertTrue(c.contains(one));
629 +        }
630 +        {
631 +            final AtomicLong count = new AtomicLong(0);
632 +            final Collection c = impl.emptyCollection();
633 +            final Spliterator split = c.spliterator();
634 +            c.add(one);
635 +            split.forEachRemaining(
636 +                e -> { assertSame(e, one); count.getAndIncrement(); });
637 +            assertEquals(1L, count.get());
638 +            assertFalse(split.tryAdvance(e -> { throw new AssertionError(); }));
639 +            assertTrue(c.contains(one));
640 +        }
641 +    }
642 +
643   //     public void testCollection8DebugFail() {
644   //         fail(impl.klazz().getSimpleName());
645   //     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines