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.30 by jsr166, Wed Nov 23 00:25:16 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 +        // Immutable (snapshot) spliterators are exempt
617 +        if (impl.emptyCollection().spliterator()
618 +            .hasCharacteristics(Spliterator.IMMUTABLE))
619 +            return;
620 +        final Object one = impl.makeElement(1);
621 +        {
622 +            final Collection c = impl.emptyCollection();
623 +            final Spliterator split = c.spliterator();
624 +            c.add(one);
625 +            assertTrue(split.tryAdvance(e -> { assertSame(e, one); }));
626 +            assertFalse(split.tryAdvance(e -> { throw new AssertionError(); }));
627 +            assertTrue(c.contains(one));
628 +        }
629 +        {
630 +            final AtomicLong count = new AtomicLong(0);
631 +            final Collection c = impl.emptyCollection();
632 +            final Spliterator split = c.spliterator();
633 +            c.add(one);
634 +            split.forEachRemaining(
635 +                e -> { assertSame(e, one); count.getAndIncrement(); });
636 +            assertEquals(1L, count.get());
637 +            assertFalse(split.tryAdvance(e -> { throw new AssertionError(); }));
638 +            assertTrue(c.contains(one));
639 +        }
640 +    }
641 +
642   //     public void testCollection8DebugFail() {
643   //         fail(impl.klazz().getSimpleName());
644   //     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines