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.14 by jsr166, Mon Apr 1 20:06:25 2013 UTC vs.
Revision 1.16 by jsr166, Thu Apr 4 04:01:05 2013 UTC

# Line 355 | Line 355 | public class CompletableFutureTest exten
355      }
356  
357      static final class IntegerHandler implements BiFunction<Integer, Throwable, Integer> {
358 +        boolean ran;
359          public Integer apply(Integer x, Throwable t) {
360 +            ran = true;
361              return (t == null) ? two : three;
362          }
363      }
# Line 384 | Line 386 | public class CompletableFutureTest exten
386       * normal or exceptional completion of source
387       */
388      public void testHandle() {
389 <        CompletableFuture<Integer> f = new CompletableFuture<Integer>();
390 <        IntegerHandler r = new IntegerHandler();
391 <        CompletableFuture<Integer> g = f.handle(r);
389 >        CompletableFuture<Integer> f, g;
390 >        IntegerHandler r;
391 >
392 >        f = new CompletableFuture<Integer>();
393 >        f.completeExceptionally(new CFException());
394 >        g = f.handle(r = new IntegerHandler());
395 >        assertTrue(r.ran);
396 >        checkCompletedNormally(g, three);
397 >
398 >        f = new CompletableFuture<Integer>();
399 >        g = f.handle(r = new IntegerHandler());
400 >        assertFalse(r.ran);
401          f.completeExceptionally(new CFException());
402          checkCompletedNormally(g, three);
403 +        assertTrue(r.ran);
404 +
405 +        f = new CompletableFuture<Integer>();
406 +        f.complete(one);
407 +        g = f.handle(r = new IntegerHandler());
408 +        assertTrue(r.ran);
409 +        checkCompletedNormally(g, two);
410  
411          f = new CompletableFuture<Integer>();
412 <        r = new IntegerHandler();
413 <        g = f.handle(r);
412 >        g = f.handle(r = new IntegerHandler());
413 >        assertFalse(r.ran);
414          f.complete(one);
415 +        assertTrue(r.ran);
416          checkCompletedNormally(g, two);
417      }
418  
# Line 2404 | Line 2423 | public class CompletableFutureTest exten
2423          Runnable[] throwingActions = {
2424              () -> { CompletableFuture.supplyAsync(null); },
2425              () -> { CompletableFuture.supplyAsync(null, exec); },
2426 <            () -> { CompletableFuture.supplyAsync(() -> one, null); },
2426 >            () -> { CompletableFuture.supplyAsync(supplyOne, null); },
2427  
2428              () -> { CompletableFuture.runAsync(null); },
2429              () -> { CompletableFuture.runAsync(null, exec); },
# Line 2493 | Line 2512 | public class CompletableFutureTest exten
2512              () -> { CompletableFuture.anyOf((CompletableFuture<?>[])null); },
2513              () -> { CompletableFuture.anyOf(f, null); },
2514              () -> { CompletableFuture.anyOf(null, f); },
2496
2497            // TODO: Crashes javac with lambda-8-2013-03-31...
2498            //() -> { CompletableFuture<?> x = f.thenAccept(null); },
2499            //() -> { CompletableFuture<Void> x = f.thenRun(null); },
2500            //() -> { CompletableFuture<Integer> x = f.thenApply(() -> { ; }); },
2515          };
2516  
2517          assertThrows(NullPointerException.class, throwingActions);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines