--- jsr166/src/test/tck/CompletableFutureTest.java 2013/04/01 20:06:25 1.14 +++ jsr166/src/test/tck/CompletableFutureTest.java 2013/04/04 04:01:05 1.16 @@ -355,7 +355,9 @@ public class CompletableFutureTest exten } static final class IntegerHandler implements BiFunction { + boolean ran; public Integer apply(Integer x, Throwable t) { + ran = true; return (t == null) ? two : three; } } @@ -384,16 +386,33 @@ public class CompletableFutureTest exten * normal or exceptional completion of source */ public void testHandle() { - CompletableFuture f = new CompletableFuture(); - IntegerHandler r = new IntegerHandler(); - CompletableFuture g = f.handle(r); + CompletableFuture f, g; + IntegerHandler r; + + f = new CompletableFuture(); + f.completeExceptionally(new CFException()); + g = f.handle(r = new IntegerHandler()); + assertTrue(r.ran); + checkCompletedNormally(g, three); + + f = new CompletableFuture(); + g = f.handle(r = new IntegerHandler()); + assertFalse(r.ran); f.completeExceptionally(new CFException()); checkCompletedNormally(g, three); + assertTrue(r.ran); + + f = new CompletableFuture(); + f.complete(one); + g = f.handle(r = new IntegerHandler()); + assertTrue(r.ran); + checkCompletedNormally(g, two); f = new CompletableFuture(); - r = new IntegerHandler(); - g = f.handle(r); + g = f.handle(r = new IntegerHandler()); + assertFalse(r.ran); f.complete(one); + assertTrue(r.ran); checkCompletedNormally(g, two); } @@ -2404,7 +2423,7 @@ public class CompletableFutureTest exten Runnable[] throwingActions = { () -> { CompletableFuture.supplyAsync(null); }, () -> { CompletableFuture.supplyAsync(null, exec); }, - () -> { CompletableFuture.supplyAsync(() -> one, null); }, + () -> { CompletableFuture.supplyAsync(supplyOne, null); }, () -> { CompletableFuture.runAsync(null); }, () -> { CompletableFuture.runAsync(null, exec); }, @@ -2493,11 +2512,6 @@ public class CompletableFutureTest exten () -> { CompletableFuture.anyOf((CompletableFuture[])null); }, () -> { CompletableFuture.anyOf(f, null); }, () -> { CompletableFuture.anyOf(null, f); }, - - // TODO: Crashes javac with lambda-8-2013-03-31... - //() -> { CompletableFuture x = f.thenAccept(null); }, - //() -> { CompletableFuture x = f.thenRun(null); }, - //() -> { CompletableFuture x = f.thenApply(() -> { ; }); }, }; assertThrows(NullPointerException.class, throwingActions);