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.208 by jsr166, Sun Sep 23 15:29:31 2018 UTC vs.
Revision 1.209 by jsr166, Sun Sep 23 17:02:24 2018 UTC

# Line 3168 | Line 3168 | public class CompletableFutureTest exten
3168          if (createIncomplete) assertTrue(f.complete(v1));
3169  
3170          if (!createIncomplete && testImplementationDetails)
3171 <            assertSame(f, g);
3171 >            assertSame(f, g);   // an optimization
3172 >
3173          checkCompletedNormally(f, v1);
3174          checkCompletedNormally(g, v1);
3175          r.assertNotInvoked();
# Line 3216 | Line 3217 | public class CompletableFutureTest exten
3217          r.assertInvoked();
3218      }}
3219  
3220 +    /**
3221 +     * thenComposeExceptionally result completes exceptionally if the
3222 +     * result of the action does
3223 +     */
3224 +    public void testExceptionallyCompose_actionReturnsFailingFuture() {
3225 +        for (ExecutionMode m : ExecutionMode.values())
3226 +        for (int order = 0; order < 6; order++)
3227 +        for (Integer v1 : new Integer[] { 1, null })
3228 +    {
3229 +        final CFException ex0 = new CFException();
3230 +        final CFException ex = new CFException();
3231 +        final CompletableFuture<Integer> f = new CompletableFuture<>();
3232 +        final CompletableFuture<Integer> g = new CompletableFuture<>();
3233 +        final CompletableFuture<Integer> h;
3234 +        // Test all permutations of orders
3235 +        switch (order) {
3236 +        case 0:
3237 +            assertTrue(f.completeExceptionally(ex0));
3238 +            assertTrue(g.completeExceptionally(ex));
3239 +            h = m.exceptionallyCompose(f, (x -> g));
3240 +            break;
3241 +        case 1:
3242 +            assertTrue(f.completeExceptionally(ex0));
3243 +            h = m.exceptionallyCompose(f, (x -> g));
3244 +            assertTrue(g.completeExceptionally(ex));
3245 +            break;
3246 +        case 2:
3247 +            assertTrue(g.completeExceptionally(ex));
3248 +            assertTrue(f.completeExceptionally(ex0));
3249 +            h = m.exceptionallyCompose(f, (x -> g));
3250 +            break;
3251 +        case 3:
3252 +            assertTrue(g.completeExceptionally(ex));
3253 +            h = m.exceptionallyCompose(f, (x -> g));
3254 +            assertTrue(f.completeExceptionally(ex0));
3255 +            break;
3256 +        case 4:
3257 +            h = m.exceptionallyCompose(f, (x -> g));
3258 +            assertTrue(f.completeExceptionally(ex0));
3259 +            assertTrue(g.completeExceptionally(ex));
3260 +            break;
3261 +        case 5:
3262 +            h = m.exceptionallyCompose(f, (x -> g));
3263 +            assertTrue(f.completeExceptionally(ex0));
3264 +            assertTrue(g.completeExceptionally(ex));
3265 +            break;
3266 +        default: throw new AssertionError();
3267 +        }
3268 +
3269 +        checkCompletedExceptionally(g, ex);
3270 +
3271 +        // TODO: should this be: checkCompletedWithWrappedException(h, ex);
3272 +        try {
3273 +            h.join();
3274 +            shouldThrow();
3275 +        } catch (Throwable t) {
3276 +            assertSame(ex, (t instanceof CompletionException) ? t.getCause() : t);
3277 +        }
3278 +
3279 +        checkCompletedExceptionally(f, ex0);
3280 +    }}
3281  
3282      // other static methods
3283  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines