ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.81 by jsr166, Mon Jun 16 17:41:26 2014 UTC vs.
Revision 1.82 by jsr166, Mon Jun 16 18:04:07 2014 UTC

# Line 3118 | Line 3118 | public class CompletableFutureTest exten
3118          assertSame(f, f.toCompletableFuture());
3119      }
3120  
3121 +    //--- tests of implementation details; not part of official tck ---
3122 +
3123 +    Object resultOf(CompletableFuture<?> f) {
3124 +        try {
3125 +            java.lang.reflect.Field resultField
3126 +                = CompletableFuture.class.getDeclaredField("result");
3127 +            resultField.setAccessible(true);
3128 +            return resultField.get(f);
3129 +        } catch (Throwable t) { throw new AssertionError(t); }
3130 +    }
3131 +
3132 +    public void testExceptionPropagationReusesResultObject() {
3133 +        if (!testImplementationDetails) return;
3134 +        for (ExecutionMode m : ExecutionMode.values())
3135 +    {
3136 +        final CompletableFuture<Void> f = new CompletableFuture<>();
3137 +        CFException ex = new CFException();
3138 +        f.completeExceptionally(ex);
3139 +        final CompletableFuture<Void> g = f.thenRun(new Noop(m));
3140 +        checkCompletedWithWrappedException(g, ex);
3141 +        final CompletableFuture<Void> h = g.thenRun(new Noop(m));
3142 +        checkCompletedWithWrappedException(h, ex);
3143 +        assertSame(resultOf(g), resultOf(h));
3144 +    }}
3145 +
3146   //     public void testRunAfterEither_resultDeterminedAtTimeOfCreation() {
3147   //         for (ExecutionMode m : ExecutionMode.values())
3148   //         for (boolean mayInterruptIfRunning : new boolean[] { true, false })

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines