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.51 by jsr166, Mon Jun 2 19:49:28 2014 UTC vs.
Revision 1.62 by jsr166, Fri Jun 6 01:19:22 2014 UTC

# Line 284 | Line 284 | public class CompletableFutureTest exten
284      public void testGetNumberOfDependents() {
285          CompletableFuture<Integer> f = new CompletableFuture<>();
286          assertEquals(0, f.getNumberOfDependents());
287 <        CompletableFuture g = f.thenRun(new Noop());
287 >        CompletableFuture g = f.thenRun(new Noop(ExecutionMode.DEFAULT));
288          assertEquals(1, f.getNumberOfDependents());
289          assertEquals(0, g.getNumberOfDependents());
290 <        CompletableFuture h = f.thenRun(new Noop());
290 >        CompletableFuture h = f.thenRun(new Noop(ExecutionMode.DEFAULT));
291          assertEquals(2, f.getNumberOfDependents());
292          f.complete(1);
293          checkCompletedNormally(g, null);
# Line 320 | Line 320 | public class CompletableFutureTest exten
320          checkCompletedNormally(f, "test");
321      }
322  
323 <    // Choose non-commutative actions for better coverage
323 >    abstract class CheckedAction {
324 >        int invocationCount = 0;
325 >        final ExecutionMode m;
326 >        CheckedAction(ExecutionMode m) { this.m = m; }
327 >        void invoked() {
328 >            m.checkExecutionMode();
329 >            assertEquals(0, invocationCount++);
330 >        }
331 >        void assertNotInvoked() { assertEquals(0, invocationCount); }
332 >        void assertInvoked() { assertEquals(1, invocationCount); }
333 >    }
334  
335 <    // A non-commutative function that handles and produces null values as well.
336 <    static Integer subtract(Integer x, Integer y) {
337 <        return (x == null && y == null) ? null :
338 <            ((x == null) ? 42 : x.intValue())
339 <            - ((y == null) ? 99 : y.intValue());
335 >    abstract class CheckedIntegerAction extends CheckedAction {
336 >        Integer value;
337 >        CheckedIntegerAction(ExecutionMode m) { super(m); }
338 >        void assertValue(Integer expected) {
339 >            assertInvoked();
340 >            assertEquals(expected, value);
341 >        }
342 >    }
343 >
344 >    class IntegerSupplier extends CheckedAction
345 >        implements Supplier<Integer>
346 >    {
347 >        final Integer value;
348 >        IntegerSupplier(ExecutionMode m, Integer value) {
349 >            super(m);
350 >            this.value = value;
351 >        }
352 >        public Integer get() {
353 >            invoked();
354 >            return value;
355 >        }
356      }
357  
358      // A function that handles and produces null values as well.
# Line 334 | Line 360 | public class CompletableFutureTest exten
360          return (x == null) ? null : x + 1;
361      }
362  
363 <    static final Supplier<Integer> supplyOne =
364 <        () -> Integer.valueOf(1);
365 <    static final Function<Integer, Integer> inc =
366 <        (Integer x) -> Integer.valueOf(x.intValue() + 1);
341 <    static final BiFunction<Integer, Integer, Integer> subtract =
342 <        (Integer x, Integer y) -> subtract(x, y);
343 <    static final class IncAction implements Consumer<Integer> {
344 <        int invocationCount = 0;
345 <        Integer value;
363 >    class IncAction extends CheckedIntegerAction
364 >        implements Consumer<Integer>
365 >    {
366 >        IncAction(ExecutionMode m) { super(m); }
367          public void accept(Integer x) {
368 <            invocationCount++;
368 >            invoked();
369              value = inc(x);
370          }
371      }
372 <    static final class IncFunction implements Function<Integer,Integer> {
373 <        int invocationCount = 0;
374 <        Integer value;
372 >
373 >    class IncFunction extends CheckedIntegerAction
374 >        implements Function<Integer,Integer>
375 >    {
376 >        IncFunction(ExecutionMode m) { super(m); }
377          public Integer apply(Integer x) {
378 <            invocationCount++;
378 >            invoked();
379              return value = inc(x);
380          }
381      }
382 <    static final class SubtractAction implements BiConsumer<Integer, Integer> {
383 <        int invocationCount = 0;
384 <        Integer value;
385 <        // Check this action was invoked exactly once when result is computed.
382 >
383 >    // Choose non-commutative actions for better coverage
384 >    // A non-commutative function that handles and produces null values as well.
385 >    static Integer subtract(Integer x, Integer y) {
386 >        return (x == null && y == null) ? null :
387 >            ((x == null) ? 42 : x.intValue())
388 >            - ((y == null) ? 99 : y.intValue());
389 >    }
390 >
391 >    class SubtractAction extends CheckedIntegerAction
392 >        implements BiConsumer<Integer, Integer>
393 >    {
394 >        SubtractAction(ExecutionMode m) { super(m); }
395          public void accept(Integer x, Integer y) {
396 <            invocationCount++;
396 >            invoked();
397              value = subtract(x, y);
398          }
399      }
400 <    static final class SubtractFunction implements BiFunction<Integer, Integer, Integer> {
401 <        int invocationCount = 0;
402 <        Integer value;
403 <        // Check this action was invoked exactly once when result is computed.
400 >
401 >    class SubtractFunction extends CheckedIntegerAction
402 >        implements BiFunction<Integer, Integer, Integer>
403 >    {
404 >        SubtractFunction(ExecutionMode m) { super(m); }
405          public Integer apply(Integer x, Integer y) {
406 <            invocationCount++;
406 >            invoked();
407              return value = subtract(x, y);
408          }
409      }
410 <    static final class Noop implements Runnable {
411 <        int invocationCount = 0;
410 >
411 >    class Noop extends CheckedAction implements Runnable {
412 >        Noop(ExecutionMode m) { super(m); }
413          public void run() {
414 <            invocationCount++;
414 >            invoked();
415          }
416      }
417  
418 <    static final class FailingSupplier implements Supplier<Integer> {
419 <        int invocationCount = 0;
418 >    class FailingSupplier extends CheckedAction implements Supplier<Integer>
419 >    {
420 >        FailingSupplier(ExecutionMode m) { super(m); }
421          public Integer get() {
422 <            invocationCount++;
422 >            invoked();
423              throw new CFException();
424          }
425      }
426 <    static final class FailingConsumer implements Consumer<Integer> {
427 <        int invocationCount = 0;
426 >
427 >    class FailingConsumer extends CheckedAction implements Consumer<Integer> {
428 >        FailingConsumer(ExecutionMode m) { super(m); }
429          public void accept(Integer x) {
430 <            invocationCount++;
430 >            invoked();
431              throw new CFException();
432          }
433      }
434 <    static final class FailingBiConsumer implements BiConsumer<Integer, Integer> {
435 <        int invocationCount = 0;
434 >
435 >    class FailingBiConsumer extends CheckedAction
436 >        implements BiConsumer<Integer, Integer>
437 >    {
438 >        FailingBiConsumer(ExecutionMode m) { super(m); }
439          public void accept(Integer x, Integer y) {
440 <            invocationCount++;
440 >            invoked();
441              throw new CFException();
442          }
443      }
444 <    static final class FailingFunction implements Function<Integer, Integer> {
445 <        int invocationCount = 0;
444 >
445 >    class FailingFunction extends CheckedAction
446 >        implements Function<Integer, Integer>
447 >    {
448 >        FailingFunction(ExecutionMode m) { super(m); }
449          public Integer apply(Integer x) {
450 <            invocationCount++;
450 >            invoked();
451              throw new CFException();
452          }
453      }
454 <    static final class FailingBiFunction implements BiFunction<Integer, Integer, Integer> {
455 <        int invocationCount = 0;
454 >
455 >    class FailingBiFunction extends CheckedAction
456 >        implements BiFunction<Integer, Integer, Integer>
457 >    {
458 >        FailingBiFunction(ExecutionMode m) { super(m); }
459          public Integer apply(Integer x, Integer y) {
460 <            invocationCount++;
460 >            invoked();
461              throw new CFException();
462          }
463      }
464 <    static final class FailingRunnable implements Runnable {
465 <        int invocationCount = 0;
464 >
465 >    class FailingRunnable extends CheckedAction implements Runnable {
466 >        FailingRunnable(ExecutionMode m) { super(m); }
467          public void run() {
468 <            invocationCount++;
468 >            invoked();
469              throw new CFException();
470          }
471      }
472  
473 <    static final class CompletableFutureInc
474 <        implements Function<Integer, CompletableFuture<Integer>> {
475 <        int invocationCount = 0;
473 >
474 >    class CompletableFutureInc extends CheckedAction
475 >        implements Function<Integer, CompletableFuture<Integer>>
476 >    {
477 >        CompletableFutureInc(ExecutionMode m) { super(m); }
478          public CompletableFuture<Integer> apply(Integer x) {
479 <            invocationCount++;
479 >            invoked();
480              CompletableFuture<Integer> f = new CompletableFuture<>();
481              f.complete(inc(x));
482              return f;
483          }
484      }
485  
486 <    static final class FailingCompletableFutureFunction
487 <        implements Function<Integer, CompletableFuture<Integer>> {
488 <        int invocationCount = 0;
486 >    class FailingCompletableFutureFunction extends CheckedAction
487 >        implements Function<Integer, CompletableFuture<Integer>>
488 >    {
489 >        FailingCompletableFutureFunction(ExecutionMode m) { super(m); }
490          public CompletableFuture<Integer> apply(Integer x) {
491 <            invocationCount++;
491 >            invoked();
492              throw new CFException();
493          }
494      }
495  
496      // Used for explicit executor tests
497      static final class ThreadExecutor implements Executor {
498 <        AtomicInteger count = new AtomicInteger(0);
498 >        final AtomicInteger count = new AtomicInteger(0);
499 >        static final ThreadGroup tg = new ThreadGroup("ThreadExecutor");
500 >        static boolean startedCurrentThread() {
501 >            return Thread.currentThread().getThreadGroup() == tg;
502 >        }
503  
504          public void execute(Runnable r) {
505              count.getAndIncrement();
506 <            new Thread(r).start();
506 >            new Thread(tg, r).start();
507          }
508      }
509  
510      /**
511       * Permits the testing of parallel code for the 3 different
512 <     * execution modes without repeating all the testing code.
512 >     * execution modes without copy/pasting all the test methods.
513       */
514      enum ExecutionMode {
515          DEFAULT {
516              public void checkExecutionMode() {
517 +                assertFalse(ThreadExecutor.startedCurrentThread());
518                  assertNull(ForkJoinTask.getPool());
519              }
520 +            public CompletableFuture<Void> runAsync(Runnable a) {
521 +                throw new UnsupportedOperationException();
522 +            }
523 +            public <U> CompletableFuture<U> supplyAsync(Supplier<U> a) {
524 +                throw new UnsupportedOperationException();
525 +            }
526              public <T> CompletableFuture<Void> thenRun
527                  (CompletableFuture<T> f, Runnable a) {
528                  return f.thenRun(a);
# Line 531 | Line 591 | public class CompletableFutureTest exten
591                  assertSame(ForkJoinPool.commonPool(),
592                             ForkJoinTask.getPool());
593              }
594 +            public CompletableFuture<Void> runAsync(Runnable a) {
595 +                return CompletableFuture.runAsync(a);
596 +            }
597 +            public <U> CompletableFuture<U> supplyAsync(Supplier<U> a) {
598 +                return CompletableFuture.supplyAsync(a);
599 +            }
600              public <T> CompletableFuture<Void> thenRun
601                  (CompletableFuture<T> f, Runnable a) {
602                  return f.thenRunAsync(a);
# Line 596 | Line 662 | public class CompletableFutureTest exten
662  
663          EXECUTOR {
664              public void checkExecutionMode() {
665 <                //TODO
665 >                assertTrue(ThreadExecutor.startedCurrentThread());
666 >            }
667 >            public CompletableFuture<Void> runAsync(Runnable a) {
668 >                return CompletableFuture.runAsync(a, new ThreadExecutor());
669 >            }
670 >            public <U> CompletableFuture<U> supplyAsync(Supplier<U> a) {
671 >                return CompletableFuture.supplyAsync(a, new ThreadExecutor());
672              }
673              public <T> CompletableFuture<Void> thenRun
674                  (CompletableFuture<T> f, Runnable a) {
# Line 662 | Line 734 | public class CompletableFutureTest exten
734          };
735  
736          public abstract void checkExecutionMode();
737 +        public abstract CompletableFuture<Void> runAsync(Runnable a);
738 +        public abstract <U> CompletableFuture<U> supplyAsync(Supplier<U> a);
739          public abstract <T> CompletableFuture<Void> thenRun
740              (CompletableFuture<T> f, Runnable a);
741          public abstract <T> CompletableFuture<Void> thenAccept
# Line 740 | Line 814 | public class CompletableFutureTest exten
814          if (!createIncomplete) f.completeExceptionally(ex);
815          final CompletableFuture<Integer> g = f.exceptionally
816              ((Throwable t) -> {
817 +                ExecutionMode.DEFAULT.checkExecutionMode();
818                  threadAssertSame(t, ex);
819                  a.getAndIncrement();
820                  return v1;
# Line 761 | Line 836 | public class CompletableFutureTest exten
836          if (!createIncomplete) f.completeExceptionally(ex1);
837          final CompletableFuture<Integer> g = f.exceptionally
838              ((Throwable t) -> {
839 +                ExecutionMode.DEFAULT.checkExecutionMode();
840                  threadAssertSame(t, ex1);
841                  a.getAndIncrement();
842                  throw ex2;
# Line 786 | Line 862 | public class CompletableFutureTest exten
862          final CompletableFuture<Integer> g = m.handle
863              (f,
864               (Integer x, Throwable t) -> {
865 +                m.checkExecutionMode();
866                  threadAssertSame(x, v1);
867                  threadAssertNull(t);
868                  a.getAndIncrement();
# Line 814 | Line 891 | public class CompletableFutureTest exten
891          final CompletableFuture<Integer> g = m.handle
892              (f,
893               (Integer x, Throwable t) -> {
894 +                m.checkExecutionMode();
895                  threadAssertNull(x);
896                  threadAssertSame(t, ex);
897                  a.getAndIncrement();
# Line 842 | Line 920 | public class CompletableFutureTest exten
920          final CompletableFuture<Integer> g = m.handle
921              (f,
922               (Integer x, Throwable t) -> {
923 +                m.checkExecutionMode();
924                  threadAssertNull(x);
925                  threadAssertTrue(t instanceof CancellationException);
926                  a.getAndIncrement();
# Line 869 | Line 948 | public class CompletableFutureTest exten
948          final CompletableFuture<Integer> g = m.handle
949              (f,
950               (Integer x, Throwable t) -> {
951 +                m.checkExecutionMode();
952                  threadAssertNull(x);
953                  threadAssertSame(ex1, t);
954                  a.getAndIncrement();
# Line 893 | Line 973 | public class CompletableFutureTest exten
973          final CompletableFuture<Integer> g = m.handle
974              (f,
975               (Integer x, Throwable t) -> {
976 +                m.checkExecutionMode();
977                  threadAssertSame(x, v1);
978                  threadAssertNull(t);
979                  a.getAndIncrement();
# Line 908 | Line 989 | public class CompletableFutureTest exten
989      /**
990       * runAsync completes after running Runnable
991       */
992 <    public void testRunAsync() {
993 <        Noop r = new Noop();
994 <        CompletableFuture<Void> f = CompletableFuture.runAsync(r);
995 <        assertNull(f.join());
996 <        assertEquals(1, r.invocationCount);
997 <        checkCompletedNormally(f, null);
998 <    }
999 <
1000 <    /**
920 <     * runAsync with executor completes after running Runnable
921 <     */
922 <    public void testRunAsync2() {
923 <        Noop r = new Noop();
924 <        ThreadExecutor exec = new ThreadExecutor();
925 <        CompletableFuture<Void> f = CompletableFuture.runAsync(r, exec);
992 >    public void testRunAsync_normalCompletion() {
993 >        ExecutionMode[] executionModes = {
994 >            ExecutionMode.ASYNC,
995 >            ExecutionMode.EXECUTOR,
996 >        };
997 >        for (ExecutionMode m : executionModes)
998 >    {
999 >        final Noop r = new Noop(m);
1000 >        final CompletableFuture<Void> f = m.runAsync(r);
1001          assertNull(f.join());
927        assertEquals(1, r.invocationCount);
1002          checkCompletedNormally(f, null);
1003 <        assertEquals(1, exec.count.get());
1004 <    }
1003 >        r.assertInvoked();
1004 >    }}
1005  
1006      /**
1007       * failing runAsync completes exceptionally after running Runnable
1008       */
1009 <    public void testRunAsync3() {
1010 <        FailingRunnable r = new FailingRunnable();
1011 <        CompletableFuture<Void> f = CompletableFuture.runAsync(r);
1009 >    public void testRunAsync_exceptionalCompletion() {
1010 >        ExecutionMode[] executionModes = {
1011 >            ExecutionMode.ASYNC,
1012 >            ExecutionMode.EXECUTOR,
1013 >        };
1014 >        for (ExecutionMode m : executionModes)
1015 >    {
1016 >        final FailingRunnable r = new FailingRunnable(m);
1017 >        final CompletableFuture<Void> f = m.runAsync(r);
1018          checkCompletedWithWrappedCFException(f);
1019 <        assertEquals(1, r.invocationCount);
1020 <    }
1019 >        r.assertInvoked();
1020 >    }}
1021  
1022      /**
1023       * supplyAsync completes with result of supplier
1024       */
1025 <    public void testSupplyAsync() {
1026 <        CompletableFuture<Integer> f;
1027 <        f = CompletableFuture.supplyAsync(supplyOne);
1028 <        assertEquals(f.join(), one);
1029 <        checkCompletedNormally(f, one);
1030 <    }
1031 <
1032 <    /**
1033 <     * supplyAsync with executor completes with result of supplier
1034 <     */
1035 <    public void testSupplyAsync2() {
1036 <        CompletableFuture<Integer> f;
1037 <        f = CompletableFuture.supplyAsync(supplyOne, new ThreadExecutor());
1038 <        assertEquals(f.join(), one);
959 <        checkCompletedNormally(f, one);
960 <    }
1025 >    public void testSupplyAsync_normalCompletion() {
1026 >        ExecutionMode[] executionModes = {
1027 >            ExecutionMode.ASYNC,
1028 >            ExecutionMode.EXECUTOR,
1029 >        };
1030 >        for (ExecutionMode m : executionModes)
1031 >        for (Integer v1 : new Integer[] { 1, null })
1032 >    {
1033 >        final IntegerSupplier r = new IntegerSupplier(m, v1);
1034 >        final CompletableFuture<Integer> f = m.supplyAsync(r);
1035 >        assertSame(v1, f.join());
1036 >        checkCompletedNormally(f, v1);
1037 >        r.assertInvoked();
1038 >    }}
1039  
1040      /**
1041       * Failing supplyAsync completes exceptionally
1042       */
1043 <    public void testSupplyAsync3() {
1044 <        FailingSupplier r = new FailingSupplier();
1045 <        CompletableFuture<Integer> f = CompletableFuture.supplyAsync(r);
1043 >    public void testSupplyAsync_exceptionalCompletion() {
1044 >        ExecutionMode[] executionModes = {
1045 >            ExecutionMode.ASYNC,
1046 >            ExecutionMode.EXECUTOR,
1047 >        };
1048 >        for (ExecutionMode m : executionModes)
1049 >    {
1050 >        FailingSupplier r = new FailingSupplier(m);
1051 >        CompletableFuture<Integer> f = m.supplyAsync(r);
1052          checkCompletedWithWrappedCFException(f);
1053 <        assertEquals(1, r.invocationCount);
1054 <    }
1053 >        r.assertInvoked();
1054 >    }}
1055  
1056      // seq completion methods
1057  
# Line 980 | Line 1064 | public class CompletableFutureTest exten
1064          for (Integer v1 : new Integer[] { 1, null })
1065      {
1066          final CompletableFuture<Integer> f = new CompletableFuture<>();
1067 <        final Noop r = new Noop();
1067 >        final Noop r = new Noop(m);
1068          if (!createIncomplete) f.complete(v1);
1069          final CompletableFuture<Void> g = m.thenRun(f, r);
1070          if (createIncomplete) {
# Line 990 | Line 1074 | public class CompletableFutureTest exten
1074  
1075          checkCompletedNormally(g, null);
1076          checkCompletedNormally(f, v1);
1077 <        assertEquals(1, r.invocationCount);
1077 >        r.assertInvoked();
1078      }}
1079  
1080      /**
# Line 1003 | Line 1087 | public class CompletableFutureTest exten
1087      {
1088          final CFException ex = new CFException();
1089          final CompletableFuture<Integer> f = new CompletableFuture<>();
1090 <        final Noop r = new Noop();
1090 >        final Noop r = new Noop(m);
1091          if (!createIncomplete) f.completeExceptionally(ex);
1092          final CompletableFuture<Void> g = m.thenRun(f, r);
1093          if (createIncomplete) {
# Line 1013 | Line 1097 | public class CompletableFutureTest exten
1097  
1098          checkCompletedWithWrappedCFException(g, ex);
1099          checkCompletedWithWrappedCFException(f, ex);
1100 <        assertEquals(0, r.invocationCount);
1100 >        r.assertNotInvoked();
1101      }}
1102  
1103      /**
# Line 1025 | Line 1109 | public class CompletableFutureTest exten
1109          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1110      {
1111          final CompletableFuture<Integer> f = new CompletableFuture<>();
1112 <        final Noop r = new Noop();
1112 >        final Noop r = new Noop(m);
1113          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1114 <        final CompletableFuture<Void> g = f.thenRun(r);
1114 >        final CompletableFuture<Void> g = m.thenRun(f, r);
1115          if (createIncomplete) {
1116              checkIncomplete(g);
1117              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 1035 | Line 1119 | public class CompletableFutureTest exten
1119  
1120          checkCompletedWithWrappedCancellationException(g);
1121          checkCancelled(f);
1122 <        assertEquals(0, r.invocationCount);
1122 >        r.assertNotInvoked();
1123      }}
1124  
1125      /**
# Line 1047 | Line 1131 | public class CompletableFutureTest exten
1131          for (Integer v1 : new Integer[] { 1, null })
1132      {
1133          final CompletableFuture<Integer> f = new CompletableFuture<>();
1134 <        final FailingRunnable r = new FailingRunnable();
1134 >        final FailingRunnable r = new FailingRunnable(m);
1135          if (!createIncomplete) f.complete(v1);
1136 <        final CompletableFuture<Void> g = f.thenRun(r);
1136 >        final CompletableFuture<Void> g = m.thenRun(f, r);
1137          if (createIncomplete) {
1138              checkIncomplete(g);
1139              f.complete(v1);
# Line 1068 | Line 1152 | public class CompletableFutureTest exten
1152          for (Integer v1 : new Integer[] { 1, null })
1153      {
1154          final CompletableFuture<Integer> f = new CompletableFuture<>();
1155 <        final IncFunction r = new IncFunction();
1155 >        final IncFunction r = new IncFunction(m);
1156          if (!createIncomplete) f.complete(v1);
1157          final CompletableFuture<Integer> g = m.thenApply(f, r);
1158          if (createIncomplete) {
# Line 1078 | Line 1162 | public class CompletableFutureTest exten
1162  
1163          checkCompletedNormally(g, inc(v1));
1164          checkCompletedNormally(f, v1);
1165 <        assertEquals(1, r.invocationCount);
1165 >        r.assertInvoked();
1166      }}
1167  
1168      /**
# Line 1091 | Line 1175 | public class CompletableFutureTest exten
1175      {
1176          final CFException ex = new CFException();
1177          final CompletableFuture<Integer> f = new CompletableFuture<>();
1178 <        final IncFunction r = new IncFunction();
1178 >        final IncFunction r = new IncFunction(m);
1179          if (!createIncomplete) f.completeExceptionally(ex);
1180          final CompletableFuture<Integer> g = m.thenApply(f, r);
1181          if (createIncomplete) {
# Line 1101 | Line 1185 | public class CompletableFutureTest exten
1185  
1186          checkCompletedWithWrappedCFException(g, ex);
1187          checkCompletedWithWrappedCFException(f, ex);
1188 <        assertEquals(0, r.invocationCount);
1188 >        r.assertNotInvoked();
1189      }}
1190  
1191      /**
# Line 1113 | Line 1197 | public class CompletableFutureTest exten
1197          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1198      {
1199          final CompletableFuture<Integer> f = new CompletableFuture<>();
1200 <        final IncFunction r = new IncFunction();
1200 >        final IncFunction r = new IncFunction(m);
1201          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1202 <        final CompletableFuture<Integer> g = f.thenApply(r);
1202 >        final CompletableFuture<Integer> g = m.thenApply(f, r);
1203          if (createIncomplete) {
1204              checkIncomplete(g);
1205              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 1123 | Line 1207 | public class CompletableFutureTest exten
1207  
1208          checkCompletedWithWrappedCancellationException(g);
1209          checkCancelled(f);
1210 <        assertEquals(0, r.invocationCount);
1210 >        r.assertNotInvoked();
1211      }}
1212  
1213      /**
# Line 1135 | Line 1219 | public class CompletableFutureTest exten
1219          for (Integer v1 : new Integer[] { 1, null })
1220      {
1221          final CompletableFuture<Integer> f = new CompletableFuture<>();
1222 <        final FailingFunction r = new FailingFunction();
1222 >        final FailingFunction r = new FailingFunction(m);
1223          if (!createIncomplete) f.complete(v1);
1224 <        final CompletableFuture<Integer> g = f.thenApply(r);
1224 >        final CompletableFuture<Integer> g = m.thenApply(f, r);
1225          if (createIncomplete) {
1226              checkIncomplete(g);
1227              f.complete(v1);
# Line 1156 | Line 1240 | public class CompletableFutureTest exten
1240          for (Integer v1 : new Integer[] { 1, null })
1241      {
1242          final CompletableFuture<Integer> f = new CompletableFuture<>();
1243 <        final IncAction r = new IncAction();
1243 >        final IncAction r = new IncAction(m);
1244          if (!createIncomplete) f.complete(v1);
1245          final CompletableFuture<Void> g = m.thenAccept(f, r);
1246          if (createIncomplete) {
# Line 1166 | Line 1250 | public class CompletableFutureTest exten
1250  
1251          checkCompletedNormally(g, null);
1252          checkCompletedNormally(f, v1);
1253 <        assertEquals(1, r.invocationCount);
1254 <        assertEquals(inc(v1), r.value);
1253 >        r.assertInvoked();
1254 >        r.assertValue(inc(v1));
1255      }}
1256  
1257      /**
# Line 1180 | Line 1264 | public class CompletableFutureTest exten
1264      {
1265          final CFException ex = new CFException();
1266          final CompletableFuture<Integer> f = new CompletableFuture<>();
1267 <        final IncAction r = new IncAction();
1267 >        final IncAction r = new IncAction(m);
1268          if (!createIncomplete) f.completeExceptionally(ex);
1269          final CompletableFuture<Void> g = m.thenAccept(f, r);
1270          if (createIncomplete) {
# Line 1190 | Line 1274 | public class CompletableFutureTest exten
1274  
1275          checkCompletedWithWrappedCFException(g, ex);
1276          checkCompletedWithWrappedCFException(f, ex);
1277 <        assertEquals(0, r.invocationCount);
1277 >        r.assertNotInvoked();
1278      }}
1279  
1280      /**
1281 <     * thenAccept result completes exceptionally if action does
1281 >     * thenAccept result completes exceptionally if source cancelled
1282       */
1283 <    public void testThenAccept_actionFailed() {
1283 >    public void testThenAccept_sourceCancelled() {
1284          for (ExecutionMode m : ExecutionMode.values())
1285          for (boolean createIncomplete : new boolean[] { true, false })
1286 <        for (Integer v1 : new Integer[] { 1, null })
1286 >        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1287      {
1288          final CompletableFuture<Integer> f = new CompletableFuture<>();
1289 <        final FailingConsumer r = new FailingConsumer();
1290 <        if (!createIncomplete) f.complete(v1);
1291 <        final CompletableFuture<Void> g = f.thenAccept(r);
1289 >        final IncAction r = new IncAction(m);
1290 >        if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1291 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1292          if (createIncomplete) {
1293              checkIncomplete(g);
1294 <            f.complete(v1);
1294 >            assertTrue(f.cancel(mayInterruptIfRunning));
1295          }
1296  
1297 <        checkCompletedWithWrappedCFException(g);
1298 <        checkCompletedNormally(f, v1);
1297 >        checkCompletedWithWrappedCancellationException(g);
1298 >        checkCancelled(f);
1299 >        r.assertNotInvoked();
1300      }}
1301  
1302      /**
1303 <     * thenAccept result completes exceptionally if source cancelled
1303 >     * thenAccept result completes exceptionally if action does
1304       */
1305 <    public void testThenAccept_sourceCancelled() {
1305 >    public void testThenAccept_actionFailed() {
1306          for (ExecutionMode m : ExecutionMode.values())
1307          for (boolean createIncomplete : new boolean[] { true, false })
1308 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1308 >        for (Integer v1 : new Integer[] { 1, null })
1309      {
1310          final CompletableFuture<Integer> f = new CompletableFuture<>();
1311 <        final IncAction r = new IncAction();
1312 <        if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1313 <        final CompletableFuture<Void> g = f.thenAccept(r);
1311 >        final FailingConsumer r = new FailingConsumer(m);
1312 >        if (!createIncomplete) f.complete(v1);
1313 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1314          if (createIncomplete) {
1315              checkIncomplete(g);
1316 <            assertTrue(f.cancel(mayInterruptIfRunning));
1316 >            f.complete(v1);
1317          }
1318  
1319 <        checkCompletedWithWrappedCancellationException(g);
1320 <        checkCancelled(f);
1236 <        assertEquals(0, r.invocationCount);
1319 >        checkCompletedWithWrappedCFException(g);
1320 >        checkCompletedNormally(f, v1);
1321      }}
1322  
1323      /**
# Line 1249 | Line 1333 | public class CompletableFutureTest exten
1333      {
1334          final CompletableFuture<Integer> f = new CompletableFuture<>();
1335          final CompletableFuture<Integer> g = new CompletableFuture<>();
1336 <        final SubtractFunction r = new SubtractFunction();
1336 >        final SubtractFunction r = new SubtractFunction(m);
1337  
1338          if (fFirst) f.complete(v1); else g.complete(v2);
1339          if (!createIncomplete)
# Line 1257 | Line 1341 | public class CompletableFutureTest exten
1341          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1342          if (createIncomplete) {
1343              checkIncomplete(h);
1344 <            assertEquals(0, r.invocationCount);
1344 >            r.assertNotInvoked();
1345              if (!fFirst) f.complete(v1); else g.complete(v2);
1346          }
1347  
1348          checkCompletedNormally(h, subtract(v1, v2));
1349          checkCompletedNormally(f, v1);
1350          checkCompletedNormally(g, v2);
1351 <        assertEquals(1, r.invocationCount);
1351 >        r.assertInvoked();
1352      }}
1353  
1354      /**
1355       * thenCombine result completes exceptionally after exceptional
1356       * completion of either source
1357       */
1358 <    public void testThenCombine_exceptionalCompletion1() {
1275 <        for (ExecutionMode m : ExecutionMode.values())
1276 <        for (Integer v1 : new Integer[] { 1, null })
1277 <    {
1278 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1279 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1280 <        final SubtractFunction r = new SubtractFunction();
1281 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1282 <        final CFException ex = new CFException();
1283 <
1284 <        f.completeExceptionally(ex);
1285 <        checkIncomplete(h);
1286 <        g.complete(v1);
1287 <
1288 <        checkCompletedWithWrappedCFException(h, ex);
1289 <        checkCompletedWithWrappedCFException(f, ex);
1290 <        assertEquals(0, r.invocationCount);
1291 <        checkCompletedNormally(g, v1);
1292 <    }}
1293 <
1294 <    public void testThenCombine_exceptionalCompletion2() {
1295 <        for (ExecutionMode m : ExecutionMode.values())
1296 <        for (Integer v1 : new Integer[] { 1, null })
1297 <    {
1298 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1299 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1300 <        final SubtractFunction r = new SubtractFunction();
1301 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1302 <        final CFException ex = new CFException();
1303 <
1304 <        g.completeExceptionally(ex);
1305 <        checkIncomplete(h);
1306 <        f.complete(v1);
1307 <
1308 <        checkCompletedWithWrappedCFException(h, ex);
1309 <        checkCompletedWithWrappedCFException(g, ex);
1310 <        assertEquals(0, r.invocationCount);
1311 <        checkCompletedNormally(f, v1);
1312 <    }}
1313 <
1314 <    public void testThenCombine_exceptionalCompletion3() {
1358 >    public void testThenCombine_exceptionalCompletion() {
1359          for (ExecutionMode m : ExecutionMode.values())
1360 +        for (boolean createIncomplete : new boolean[] { true, false })
1361 +        for (boolean fFirst : new boolean[] { true, false })
1362          for (Integer v1 : new Integer[] { 1, null })
1363      {
1364          final CompletableFuture<Integer> f = new CompletableFuture<>();
1365          final CompletableFuture<Integer> g = new CompletableFuture<>();
1320        final SubtractFunction r = new SubtractFunction();
1366          final CFException ex = new CFException();
1367 +        final SubtractFunction r = new SubtractFunction(m);
1368  
1369 <        g.completeExceptionally(ex);
1370 <        f.complete(v1);
1369 >        (fFirst ? f : g).complete(v1);
1370 >        if (!createIncomplete)
1371 >            (!fFirst ? f : g).completeExceptionally(ex);
1372          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1373 +        if (createIncomplete) {
1374 +            checkIncomplete(h);
1375 +            (!fFirst ? f : g).completeExceptionally(ex);
1376 +        }
1377  
1378          checkCompletedWithWrappedCFException(h, ex);
1379 <        checkCompletedWithWrappedCFException(g, ex);
1380 <        assertEquals(0, r.invocationCount);
1381 <        checkCompletedNormally(f, v1);
1379 >        r.assertNotInvoked();
1380 >        checkCompletedNormally(fFirst ? f : g, v1);
1381 >        checkCompletedWithWrappedCFException(!fFirst ? f : g, ex);
1382      }}
1383  
1384 <    public void testThenCombine_exceptionalCompletion4() {
1384 >    /**
1385 >     * thenCombine result completes exceptionally if either source cancelled
1386 >     */
1387 >    public void testThenCombine_sourceCancelled() {
1388          for (ExecutionMode m : ExecutionMode.values())
1389 +        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1390 +        for (boolean createIncomplete : new boolean[] { true, false })
1391 +        for (boolean fFirst : new boolean[] { true, false })
1392          for (Integer v1 : new Integer[] { 1, null })
1393      {
1394          final CompletableFuture<Integer> f = new CompletableFuture<>();
1395          final CompletableFuture<Integer> g = new CompletableFuture<>();
1396 <        final SubtractFunction r = new SubtractFunction();
1340 <        final CFException ex = new CFException();
1396 >        final SubtractFunction r = new SubtractFunction(m);
1397  
1398 <        f.completeExceptionally(ex);
1399 <        g.complete(v1);
1398 >        (fFirst ? f : g).complete(v1);
1399 >        if (!createIncomplete)
1400 >            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1401          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1402 +        if (createIncomplete) {
1403 +            checkIncomplete(h);
1404 +            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1405 +        }
1406  
1407 <        checkCompletedWithWrappedCFException(h, ex);
1408 <        checkCompletedWithWrappedCFException(f, ex);
1409 <        assertEquals(0, r.invocationCount);
1410 <        checkCompletedNormally(g, v1);
1407 >        checkCompletedWithWrappedCancellationException(h);
1408 >        checkCancelled(!fFirst ? f : g);
1409 >        r.assertNotInvoked();
1410 >        checkCompletedNormally(fFirst ? f : g, v1);
1411      }}
1412  
1413      /**
1414       * thenCombine result completes exceptionally if action does
1415       */
1416 <    public void testThenCombine_actionFailed1() {
1356 <        for (ExecutionMode m : ExecutionMode.values())
1357 <        for (Integer v1 : new Integer[] { 1, null })
1358 <        for (Integer v2 : new Integer[] { 2, null })
1359 <    {
1360 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1361 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1362 <        final FailingBiFunction r = new FailingBiFunction();
1363 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1364 <
1365 <        f.complete(v1);
1366 <        checkIncomplete(h);
1367 <        g.complete(v2);
1368 <
1369 <        checkCompletedWithWrappedCFException(h);
1370 <        checkCompletedNormally(f, v1);
1371 <        checkCompletedNormally(g, v2);
1372 <    }}
1373 <
1374 <    public void testThenCombine_actionFailed2() {
1416 >    public void testThenCombine_actionFailed() {
1417          for (ExecutionMode m : ExecutionMode.values())
1418 +        for (boolean fFirst : new boolean[] { true, false })
1419          for (Integer v1 : new Integer[] { 1, null })
1420          for (Integer v2 : new Integer[] { 2, null })
1421      {
1422          final CompletableFuture<Integer> f = new CompletableFuture<>();
1423          final CompletableFuture<Integer> g = new CompletableFuture<>();
1424 <        final FailingBiFunction r = new FailingBiFunction();
1424 >        final FailingBiFunction r = new FailingBiFunction(m);
1425          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1426  
1427 <        g.complete(v2);
1428 <        checkIncomplete(h);
1429 <        f.complete(v1);
1427 >        if (fFirst) {
1428 >            f.complete(v1);
1429 >            g.complete(v2);
1430 >        } else {
1431 >            g.complete(v2);
1432 >            f.complete(v1);
1433 >        }
1434  
1435          checkCompletedWithWrappedCFException(h);
1436          checkCompletedNormally(f, v1);
# Line 1391 | Line 1438 | public class CompletableFutureTest exten
1438      }}
1439  
1440      /**
1394     * thenCombine result completes exceptionally if either source cancelled
1395     */
1396    public void testThenCombine_sourceCancelled1() {
1397        for (ExecutionMode m : ExecutionMode.values())
1398        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1399        for (Integer v1 : new Integer[] { 1, null })
1400    {
1401        final CompletableFuture<Integer> f = new CompletableFuture<>();
1402        final CompletableFuture<Integer> g = new CompletableFuture<>();
1403        final SubtractFunction r = new SubtractFunction();
1404        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1405
1406        assertTrue(f.cancel(mayInterruptIfRunning));
1407        checkIncomplete(h);
1408        g.complete(v1);
1409
1410        checkCompletedWithWrappedCancellationException(h);
1411        checkCancelled(f);
1412        assertEquals(0, r.invocationCount);
1413        checkCompletedNormally(g, v1);
1414    }}
1415
1416    public void testThenCombine_sourceCancelled2() {
1417        for (ExecutionMode m : ExecutionMode.values())
1418        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1419        for (Integer v1 : new Integer[] { 1, null })
1420    {
1421        final CompletableFuture<Integer> f = new CompletableFuture<>();
1422        final CompletableFuture<Integer> g = new CompletableFuture<>();
1423        final SubtractFunction r = new SubtractFunction();
1424        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1425
1426        assertTrue(g.cancel(mayInterruptIfRunning));
1427        checkIncomplete(h);
1428        f.complete(v1);
1429
1430        checkCompletedWithWrappedCancellationException(h);
1431        checkCancelled(g);
1432        assertEquals(0, r.invocationCount);
1433        checkCompletedNormally(f, v1);
1434    }}
1435
1436    public void testThenCombine_sourceCancelled3() {
1437        for (ExecutionMode m : ExecutionMode.values())
1438        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1439        for (Integer v1 : new Integer[] { 1, null })
1440    {
1441        final CompletableFuture<Integer> f = new CompletableFuture<>();
1442        final CompletableFuture<Integer> g = new CompletableFuture<>();
1443        final SubtractFunction r = new SubtractFunction();
1444
1445        assertTrue(g.cancel(mayInterruptIfRunning));
1446        f.complete(v1);
1447        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1448
1449        checkCompletedWithWrappedCancellationException(h);
1450        checkCancelled(g);
1451        assertEquals(0, r.invocationCount);
1452        checkCompletedNormally(f, v1);
1453    }}
1454
1455    public void testThenCombine_sourceCancelled4() {
1456        for (ExecutionMode m : ExecutionMode.values())
1457        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1458        for (Integer v1 : new Integer[] { 1, null })
1459    {
1460        final CompletableFuture<Integer> f = new CompletableFuture<>();
1461        final CompletableFuture<Integer> g = new CompletableFuture<>();
1462        final SubtractFunction r = new SubtractFunction();
1463
1464        assertTrue(f.cancel(mayInterruptIfRunning));
1465        g.complete(v1);
1466        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1467
1468        checkCompletedWithWrappedCancellationException(h);
1469        checkCancelled(f);
1470        assertEquals(0, r.invocationCount);
1471        checkCompletedNormally(g, v1);
1472    }}
1473
1474    /**
1441       * thenAcceptBoth result completes normally after normal
1442       * completion of sources
1443       */
1444 <    public void testThenAcceptBoth_normalCompletion1() {
1479 <        for (ExecutionMode m : ExecutionMode.values())
1480 <        for (Integer v1 : new Integer[] { 1, null })
1481 <        for (Integer v2 : new Integer[] { 2, null })
1482 <    {
1483 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1484 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1485 <        final SubtractAction r = new SubtractAction();
1486 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1487 <
1488 <        f.complete(v1);
1489 <        checkIncomplete(h);
1490 <        assertEquals(0, r.invocationCount);
1491 <        g.complete(v2);
1492 <
1493 <        checkCompletedNormally(h, null);
1494 <        assertEquals(subtract(v1, v2), r.value);
1495 <        checkCompletedNormally(f, v1);
1496 <        checkCompletedNormally(g, v2);
1497 <    }}
1498 <
1499 <    public void testThenAcceptBoth_normalCompletion2() {
1500 <        for (ExecutionMode m : ExecutionMode.values())
1501 <        for (Integer v1 : new Integer[] { 1, null })
1502 <        for (Integer v2 : new Integer[] { 2, null })
1503 <    {
1504 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1505 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1506 <        final SubtractAction r = new SubtractAction();
1507 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1508 <
1509 <        g.complete(v2);
1510 <        checkIncomplete(h);
1511 <        assertEquals(0, r.invocationCount);
1512 <        f.complete(v1);
1513 <
1514 <        checkCompletedNormally(h, null);
1515 <        assertEquals(subtract(v1, v2), r.value);
1516 <        checkCompletedNormally(f, v1);
1517 <        checkCompletedNormally(g, v2);
1518 <    }}
1519 <
1520 <    public void testThenAcceptBoth_normalCompletion3() {
1521 <        for (ExecutionMode m : ExecutionMode.values())
1522 <        for (Integer v1 : new Integer[] { 1, null })
1523 <        for (Integer v2 : new Integer[] { 2, null })
1524 <    {
1525 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1526 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1527 <        final SubtractAction r = new SubtractAction();
1528 <
1529 <        g.complete(v2);
1530 <        f.complete(v1);
1531 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1532 <
1533 <        checkCompletedNormally(h, null);
1534 <        assertEquals(subtract(v1, v2), r.value);
1535 <        checkCompletedNormally(f, v1);
1536 <        checkCompletedNormally(g, v2);
1537 <    }}
1538 <
1539 <    public void testThenAcceptBoth_normalCompletion4() {
1444 >    public void testThenAcceptBoth_normalCompletion() {
1445          for (ExecutionMode m : ExecutionMode.values())
1446 +        for (boolean createIncomplete : new boolean[] { true, false })
1447 +        for (boolean fFirst : new boolean[] { true, false })
1448          for (Integer v1 : new Integer[] { 1, null })
1449          for (Integer v2 : new Integer[] { 2, null })
1450      {
1451          final CompletableFuture<Integer> f = new CompletableFuture<>();
1452          final CompletableFuture<Integer> g = new CompletableFuture<>();
1453 <        final SubtractAction r = new SubtractAction();
1453 >        final SubtractAction r = new SubtractAction(m);
1454  
1455 <        f.complete(v1);
1456 <        g.complete(v2);
1455 >        if (fFirst) f.complete(v1); else g.complete(v2);
1456 >        if (!createIncomplete)
1457 >            if (!fFirst) f.complete(v1); else g.complete(v2);
1458          final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1459 +        if (createIncomplete) {
1460 +            checkIncomplete(h);
1461 +            r.assertNotInvoked();
1462 +            if (!fFirst) f.complete(v1); else g.complete(v2);
1463 +        }
1464  
1465          checkCompletedNormally(h, null);
1466 <        assertEquals(subtract(v1, v2), r.value);
1466 >        r.assertValue(subtract(v1, v2));
1467          checkCompletedNormally(f, v1);
1468          checkCompletedNormally(g, v2);
1469      }}
# Line 1559 | Line 1472 | public class CompletableFutureTest exten
1472       * thenAcceptBoth result completes exceptionally after exceptional
1473       * completion of either source
1474       */
1475 <    public void testThenAcceptBoth_exceptionalCompletion1() {
1563 <        for (ExecutionMode m : ExecutionMode.values())
1564 <        for (Integer v1 : new Integer[] { 1, null })
1565 <    {
1566 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1567 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1568 <        final SubtractAction r = new SubtractAction();
1569 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1570 <        final CFException ex = new CFException();
1571 <
1572 <        f.completeExceptionally(ex);
1573 <        checkIncomplete(h);
1574 <        g.complete(v1);
1575 <
1576 <        checkCompletedWithWrappedCFException(h, ex);
1577 <        checkCompletedWithWrappedCFException(f, ex);
1578 <        assertEquals(0, r.invocationCount);
1579 <        checkCompletedNormally(g, v1);
1580 <    }}
1581 <
1582 <    public void testThenAcceptBoth_exceptionalCompletion2() {
1583 <        for (ExecutionMode m : ExecutionMode.values())
1584 <        for (Integer v1 : new Integer[] { 1, null })
1585 <    {
1586 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1587 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1588 <        final SubtractAction r = new SubtractAction();
1589 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1590 <        final CFException ex = new CFException();
1591 <
1592 <        g.completeExceptionally(ex);
1593 <        checkIncomplete(h);
1594 <        f.complete(v1);
1595 <
1596 <        checkCompletedWithWrappedCFException(h, ex);
1597 <        checkCompletedWithWrappedCFException(g, ex);
1598 <        assertEquals(0, r.invocationCount);
1599 <        checkCompletedNormally(f, v1);
1600 <    }}
1601 <
1602 <    public void testThenAcceptBoth_exceptionalCompletion3() {
1475 >    public void testThenAcceptBoth_exceptionalCompletion() {
1476          for (ExecutionMode m : ExecutionMode.values())
1477 +        for (boolean createIncomplete : new boolean[] { true, false })
1478 +        for (boolean fFirst : new boolean[] { true, false })
1479          for (Integer v1 : new Integer[] { 1, null })
1480      {
1481          final CompletableFuture<Integer> f = new CompletableFuture<>();
1482          final CompletableFuture<Integer> g = new CompletableFuture<>();
1608        final SubtractAction r = new SubtractAction();
1483          final CFException ex = new CFException();
1484 +        final SubtractAction r = new SubtractAction(m);
1485  
1486 <        g.completeExceptionally(ex);
1487 <        f.complete(v1);
1486 >        (fFirst ? f : g).complete(v1);
1487 >        if (!createIncomplete)
1488 >            (!fFirst ? f : g).completeExceptionally(ex);
1489          final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1490 +        if (createIncomplete) {
1491 +            checkIncomplete(h);
1492 +            (!fFirst ? f : g).completeExceptionally(ex);
1493 +        }
1494  
1495          checkCompletedWithWrappedCFException(h, ex);
1496 <        checkCompletedWithWrappedCFException(g, ex);
1497 <        assertEquals(0, r.invocationCount);
1498 <        checkCompletedNormally(f, v1);
1496 >        r.assertNotInvoked();
1497 >        checkCompletedNormally(fFirst ? f : g, v1);
1498 >        checkCompletedWithWrappedCFException(!fFirst ? f : g, ex);
1499      }}
1500  
1501 <    public void testThenAcceptBoth_exceptionalCompletion4() {
1501 >    /**
1502 >     * thenAcceptBoth result completes exceptionally if either source cancelled
1503 >     */
1504 >    public void testThenAcceptBoth_sourceCancelled() {
1505          for (ExecutionMode m : ExecutionMode.values())
1506 +        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1507 +        for (boolean createIncomplete : new boolean[] { true, false })
1508 +        for (boolean fFirst : new boolean[] { true, false })
1509          for (Integer v1 : new Integer[] { 1, null })
1510      {
1511          final CompletableFuture<Integer> f = new CompletableFuture<>();
1512          final CompletableFuture<Integer> g = new CompletableFuture<>();
1513 <        final SubtractAction r = new SubtractAction();
1628 <        final CFException ex = new CFException();
1513 >        final SubtractAction r = new SubtractAction(m);
1514  
1515 <        f.completeExceptionally(ex);
1516 <        g.complete(v1);
1515 >        (fFirst ? f : g).complete(v1);
1516 >        if (!createIncomplete)
1517 >            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1518          final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1519 +        if (createIncomplete) {
1520 +            checkIncomplete(h);
1521 +            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1522 +        }
1523  
1524 <        checkCompletedWithWrappedCFException(h, ex);
1525 <        checkCompletedWithWrappedCFException(f, ex);
1526 <        assertEquals(0, r.invocationCount);
1527 <        checkCompletedNormally(g, v1);
1524 >        checkCompletedWithWrappedCancellationException(h);
1525 >        checkCancelled(!fFirst ? f : g);
1526 >        r.assertNotInvoked();
1527 >        checkCompletedNormally(fFirst ? f : g, v1);
1528      }}
1529  
1530      /**
1531       * thenAcceptBoth result completes exceptionally if action does
1532       */
1533 <    public void testThenAcceptBoth_actionFailed1() {
1644 <        for (ExecutionMode m : ExecutionMode.values())
1645 <        for (Integer v1 : new Integer[] { 1, null })
1646 <        for (Integer v2 : new Integer[] { 2, null })
1647 <    {
1648 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1649 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1650 <        final FailingBiConsumer r = new FailingBiConsumer();
1651 <        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1652 <
1653 <        f.complete(v1);
1654 <        checkIncomplete(h);
1655 <        g.complete(v2);
1656 <
1657 <        checkCompletedWithWrappedCFException(h);
1658 <        checkCompletedNormally(f, v1);
1659 <        checkCompletedNormally(g, v2);
1660 <    }}
1661 <
1662 <    public void testThenAcceptBoth_actionFailed2() {
1533 >    public void testThenAcceptBoth_actionFailed() {
1534          for (ExecutionMode m : ExecutionMode.values())
1535 +        for (boolean fFirst : new boolean[] { true, false })
1536          for (Integer v1 : new Integer[] { 1, null })
1537          for (Integer v2 : new Integer[] { 2, null })
1538      {
1539          final CompletableFuture<Integer> f = new CompletableFuture<>();
1540          final CompletableFuture<Integer> g = new CompletableFuture<>();
1541 <        final FailingBiConsumer r = new FailingBiConsumer();
1541 >        final FailingBiConsumer r = new FailingBiConsumer(m);
1542          final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1543  
1544 <        g.complete(v2);
1545 <        checkIncomplete(h);
1546 <        f.complete(v1);
1544 >        if (fFirst) {
1545 >            f.complete(v1);
1546 >            g.complete(v2);
1547 >        } else {
1548 >            g.complete(v2);
1549 >            f.complete(v1);
1550 >        }
1551  
1552          checkCompletedWithWrappedCFException(h);
1553          checkCompletedNormally(f, v1);
# Line 1679 | Line 1555 | public class CompletableFutureTest exten
1555      }}
1556  
1557      /**
1682     * thenAcceptBoth result completes exceptionally if either source cancelled
1683     */
1684    public void testThenAcceptBoth_sourceCancelled1() {
1685        for (ExecutionMode m : ExecutionMode.values())
1686        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1687        for (Integer v1 : new Integer[] { 1, null })
1688    {
1689        final CompletableFuture<Integer> f = new CompletableFuture<>();
1690        final CompletableFuture<Integer> g = new CompletableFuture<>();
1691        final SubtractAction r = new SubtractAction();
1692        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1693
1694        assertTrue(f.cancel(mayInterruptIfRunning));
1695        checkIncomplete(h);
1696        g.complete(v1);
1697
1698        checkCompletedWithWrappedCancellationException(h);
1699        checkCancelled(f);
1700        assertEquals(0, r.invocationCount);
1701        checkCompletedNormally(g, v1);
1702    }}
1703
1704    public void testThenAcceptBoth_sourceCancelled2() {
1705        for (ExecutionMode m : ExecutionMode.values())
1706        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1707        for (Integer v1 : new Integer[] { 1, null })
1708    {
1709        final CompletableFuture<Integer> f = new CompletableFuture<>();
1710        final CompletableFuture<Integer> g = new CompletableFuture<>();
1711        final SubtractAction r = new SubtractAction();
1712        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1713
1714        assertTrue(g.cancel(mayInterruptIfRunning));
1715        checkIncomplete(h);
1716        f.complete(v1);
1717
1718        checkCompletedWithWrappedCancellationException(h);
1719        checkCancelled(g);
1720        assertEquals(0, r.invocationCount);
1721        checkCompletedNormally(f, v1);
1722    }}
1723
1724    public void testThenAcceptBoth_sourceCancelled3() {
1725        for (ExecutionMode m : ExecutionMode.values())
1726        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1727        for (Integer v1 : new Integer[] { 1, null })
1728    {
1729        final CompletableFuture<Integer> f = new CompletableFuture<>();
1730        final CompletableFuture<Integer> g = new CompletableFuture<>();
1731        final SubtractAction r = new SubtractAction();
1732
1733        assertTrue(g.cancel(mayInterruptIfRunning));
1734        f.complete(v1);
1735        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1736
1737        checkCompletedWithWrappedCancellationException(h);
1738        checkCancelled(g);
1739        assertEquals(0, r.invocationCount);
1740        checkCompletedNormally(f, v1);
1741    }}
1742
1743    public void testThenAcceptBoth_sourceCancelled4() {
1744        for (ExecutionMode m : ExecutionMode.values())
1745        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1746        for (Integer v1 : new Integer[] { 1, null })
1747    {
1748        final CompletableFuture<Integer> f = new CompletableFuture<>();
1749        final CompletableFuture<Integer> g = new CompletableFuture<>();
1750        final SubtractAction r = new SubtractAction();
1751
1752        assertTrue(f.cancel(mayInterruptIfRunning));
1753        g.complete(v1);
1754        final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1755
1756        checkCompletedWithWrappedCancellationException(h);
1757        checkCancelled(f);
1758        assertEquals(0, r.invocationCount);
1759        checkCompletedNormally(g, v1);
1760    }}
1761
1762    /**
1558       * runAfterBoth result completes normally after normal
1559       * completion of sources
1560       */
1561 <    public void testRunAfterBoth_normalCompletion1() {
1767 <        for (ExecutionMode m : ExecutionMode.values())
1768 <        for (Integer v1 : new Integer[] { 1, null })
1769 <        for (Integer v2 : new Integer[] { 2, null })
1770 <    {
1771 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1772 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1773 <        final Noop r = new Noop();
1774 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1775 <
1776 <        f.complete(v1);
1777 <        checkIncomplete(h);
1778 <        assertEquals(0, r.invocationCount);
1779 <        g.complete(v2);
1780 <
1781 <        checkCompletedNormally(h, null);
1782 <        assertEquals(1, r.invocationCount);
1783 <        checkCompletedNormally(f, v1);
1784 <        checkCompletedNormally(g, v2);
1785 <    }}
1786 <
1787 <    public void testRunAfterBoth_normalCompletion2() {
1788 <        for (ExecutionMode m : ExecutionMode.values())
1789 <        for (Integer v1 : new Integer[] { 1, null })
1790 <        for (Integer v2 : new Integer[] { 2, null })
1791 <    {
1792 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1793 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1794 <        final Noop r = new Noop();
1795 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1796 <
1797 <        g.complete(v2);
1798 <        checkIncomplete(h);
1799 <        assertEquals(0, r.invocationCount);
1800 <        f.complete(v1);
1801 <
1802 <        checkCompletedNormally(h, null);
1803 <        assertEquals(1, r.invocationCount);
1804 <        checkCompletedNormally(f, v1);
1805 <        checkCompletedNormally(g, v2);
1806 <    }}
1807 <
1808 <    public void testRunAfterBoth_normalCompletion3() {
1809 <        for (ExecutionMode m : ExecutionMode.values())
1810 <        for (Integer v1 : new Integer[] { 1, null })
1811 <        for (Integer v2 : new Integer[] { 2, null })
1812 <    {
1813 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1814 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1815 <        final Noop r = new Noop();
1816 <
1817 <        g.complete(v2);
1818 <        f.complete(v1);
1819 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1820 <
1821 <        checkCompletedNormally(h, null);
1822 <        assertEquals(1, r.invocationCount);
1823 <        checkCompletedNormally(f, v1);
1824 <        checkCompletedNormally(g, v2);
1825 <    }}
1826 <
1827 <    public void testRunAfterBoth_normalCompletion4() {
1561 >    public void testRunAfterBoth_normalCompletion() {
1562          for (ExecutionMode m : ExecutionMode.values())
1563 +        for (boolean createIncomplete : new boolean[] { true, false })
1564 +        for (boolean fFirst : new boolean[] { true, false })
1565          for (Integer v1 : new Integer[] { 1, null })
1566          for (Integer v2 : new Integer[] { 2, null })
1567      {
1568          final CompletableFuture<Integer> f = new CompletableFuture<>();
1569          final CompletableFuture<Integer> g = new CompletableFuture<>();
1570 <        final Noop r = new Noop();
1570 >        final Noop r = new Noop(m);
1571  
1572 <        f.complete(v1);
1573 <        g.complete(v2);
1572 >        if (fFirst) f.complete(v1); else g.complete(v2);
1573 >        if (!createIncomplete)
1574 >            if (!fFirst) f.complete(v1); else g.complete(v2);
1575          final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1576 +        if (createIncomplete) {
1577 +            checkIncomplete(h);
1578 +            r.assertNotInvoked();
1579 +            if (!fFirst) f.complete(v1); else g.complete(v2);
1580 +        }
1581  
1582          checkCompletedNormally(h, null);
1583 <        assertEquals(1, r.invocationCount);
1583 >        r.assertInvoked();
1584          checkCompletedNormally(f, v1);
1585          checkCompletedNormally(g, v2);
1586      }}
# Line 1847 | Line 1589 | public class CompletableFutureTest exten
1589       * runAfterBoth result completes exceptionally after exceptional
1590       * completion of either source
1591       */
1592 <    public void testRunAfterBoth_exceptionalCompletion1() {
1851 <        for (ExecutionMode m : ExecutionMode.values())
1852 <        for (Integer v1 : new Integer[] { 1, null })
1853 <    {
1854 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1855 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1856 <        final Noop r = new Noop();
1857 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1858 <        final CFException ex = new CFException();
1859 <
1860 <        f.completeExceptionally(ex);
1861 <        checkIncomplete(h);
1862 <        g.complete(v1);
1863 <
1864 <        checkCompletedWithWrappedCFException(h, ex);
1865 <        checkCompletedWithWrappedCFException(f, ex);
1866 <        assertEquals(0, r.invocationCount);
1867 <        checkCompletedNormally(g, v1);
1868 <    }}
1869 <
1870 <    public void testRunAfterBoth_exceptionalCompletion2() {
1871 <        for (ExecutionMode m : ExecutionMode.values())
1872 <        for (Integer v1 : new Integer[] { 1, null })
1873 <    {
1874 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1875 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1876 <        final Noop r = new Noop();
1877 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1878 <        final CFException ex = new CFException();
1879 <
1880 <        g.completeExceptionally(ex);
1881 <        checkIncomplete(h);
1882 <        f.complete(v1);
1883 <
1884 <        checkCompletedWithWrappedCFException(h, ex);
1885 <        checkCompletedWithWrappedCFException(g, ex);
1886 <        assertEquals(0, r.invocationCount);
1887 <        checkCompletedNormally(f, v1);
1888 <    }}
1889 <
1890 <    public void testRunAfterBoth_exceptionalCompletion3() {
1891 <        for (ExecutionMode m : ExecutionMode.values())
1892 <        for (Integer v1 : new Integer[] { 1, null })
1893 <    {
1894 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1895 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1896 <        final Noop r = new Noop();
1897 <        final CFException ex = new CFException();
1898 <
1899 <        g.completeExceptionally(ex);
1900 <        f.complete(v1);
1901 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1902 <
1903 <        checkCompletedWithWrappedCFException(h, ex);
1904 <        checkCompletedWithWrappedCFException(g, ex);
1905 <        assertEquals(0, r.invocationCount);
1906 <        checkCompletedNormally(f, v1);
1907 <    }}
1908 <
1909 <    public void testRunAfterBoth_exceptionalCompletion4() {
1592 >    public void testRunAfterBoth_exceptionalCompletion() {
1593          for (ExecutionMode m : ExecutionMode.values())
1594 +        for (boolean createIncomplete : new boolean[] { true, false })
1595 +        for (boolean fFirst : new boolean[] { true, false })
1596          for (Integer v1 : new Integer[] { 1, null })
1597      {
1598          final CompletableFuture<Integer> f = new CompletableFuture<>();
1599          final CompletableFuture<Integer> g = new CompletableFuture<>();
1915        final Noop r = new Noop();
1600          final CFException ex = new CFException();
1601 +        final Noop r = new Noop(m);
1602  
1603 <        f.completeExceptionally(ex);
1604 <        g.complete(v1);
1603 >        (fFirst ? f : g).complete(v1);
1604 >        if (!createIncomplete)
1605 >            (!fFirst ? f : g).completeExceptionally(ex);
1606          final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1607 +        if (createIncomplete) {
1608 +            checkIncomplete(h);
1609 +            (!fFirst ? f : g).completeExceptionally(ex);
1610 +        }
1611  
1612          checkCompletedWithWrappedCFException(h, ex);
1613 <        checkCompletedWithWrappedCFException(f, ex);
1614 <        assertEquals(0, r.invocationCount);
1615 <        checkCompletedNormally(g, v1);
1926 <    }}
1927 <
1928 <    /**
1929 <     * runAfterBoth result completes exceptionally if action does
1930 <     */
1931 <    public void testRunAfterBoth_actionFailed1() {
1932 <        for (ExecutionMode m : ExecutionMode.values())
1933 <        for (Integer v1 : new Integer[] { 1, null })
1934 <        for (Integer v2 : new Integer[] { 2, null })
1935 <    {
1936 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1937 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1938 <        final FailingRunnable r = new FailingRunnable();
1939 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1940 <
1941 <        f.complete(v1);
1942 <        checkIncomplete(h);
1943 <        g.complete(v2);
1944 <
1945 <        checkCompletedWithWrappedCFException(h);
1946 <        checkCompletedNormally(f, v1);
1947 <        checkCompletedNormally(g, v2);
1948 <    }}
1949 <
1950 <    public void testRunAfterBoth_actionFailed2() {
1951 <        for (ExecutionMode m : ExecutionMode.values())
1952 <        for (Integer v1 : new Integer[] { 1, null })
1953 <        for (Integer v2 : new Integer[] { 2, null })
1954 <    {
1955 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1956 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1957 <        final FailingRunnable r = new FailingRunnable();
1958 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1959 <
1960 <        g.complete(v2);
1961 <        checkIncomplete(h);
1962 <        f.complete(v1);
1963 <
1964 <        checkCompletedWithWrappedCFException(h);
1965 <        checkCompletedNormally(f, v1);
1966 <        checkCompletedNormally(g, v2);
1613 >        r.assertNotInvoked();
1614 >        checkCompletedNormally(fFirst ? f : g, v1);
1615 >        checkCompletedWithWrappedCFException(!fFirst ? f : g, ex);
1616      }}
1617  
1618      /**
1619       * runAfterBoth result completes exceptionally if either source cancelled
1620       */
1621 <    public void testRunAfterBoth_sourceCancelled1() {
1621 >    public void testRunAfterBoth_sourceCancelled() {
1622          for (ExecutionMode m : ExecutionMode.values())
1623          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1624 +        for (boolean createIncomplete : new boolean[] { true, false })
1625 +        for (boolean fFirst : new boolean[] { true, false })
1626          for (Integer v1 : new Integer[] { 1, null })
1627      {
1628          final CompletableFuture<Integer> f = new CompletableFuture<>();
1629          final CompletableFuture<Integer> g = new CompletableFuture<>();
1630 <        final Noop r = new Noop();
1980 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1981 <
1982 <        assertTrue(f.cancel(mayInterruptIfRunning));
1983 <        checkIncomplete(h);
1984 <        g.complete(v1);
1630 >        final Noop r = new Noop(m);
1631  
1986        checkCompletedWithWrappedCancellationException(h);
1987        checkCancelled(f);
1988        assertEquals(0, r.invocationCount);
1989        checkCompletedNormally(g, v1);
1990    }}
1632  
1633 <    public void testRunAfterBoth_sourceCancelled2() {
1634 <        for (ExecutionMode m : ExecutionMode.values())
1635 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1995 <        for (Integer v1 : new Integer[] { 1, null })
1996 <    {
1997 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1998 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1999 <        final Noop r = new Noop();
1633 >        (fFirst ? f : g).complete(v1);
1634 >        if (!createIncomplete)
1635 >            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1636          final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1637 <
1638 <        assertTrue(g.cancel(mayInterruptIfRunning));
1639 <        checkIncomplete(h);
1640 <        f.complete(v1);
1637 >        if (createIncomplete) {
1638 >            checkIncomplete(h);
1639 >            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1640 >        }
1641  
1642          checkCompletedWithWrappedCancellationException(h);
1643 <        checkCancelled(g);
1644 <        assertEquals(0, r.invocationCount);
1645 <        checkCompletedNormally(f, v1);
1643 >        checkCancelled(!fFirst ? f : g);
1644 >        r.assertNotInvoked();
1645 >        checkCompletedNormally(fFirst ? f : g, v1);
1646      }}
1647  
1648 <    public void testRunAfterBoth_sourceCancelled3() {
1648 >    /**
1649 >     * runAfterBoth result completes exceptionally if action does
1650 >     */
1651 >    public void testRunAfterBoth_actionFailed() {
1652          for (ExecutionMode m : ExecutionMode.values())
1653 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1653 >        for (boolean fFirst : new boolean[] { true, false })
1654          for (Integer v1 : new Integer[] { 1, null })
1655 +        for (Integer v2 : new Integer[] { 2, null })
1656      {
1657          final CompletableFuture<Integer> f = new CompletableFuture<>();
1658          final CompletableFuture<Integer> g = new CompletableFuture<>();
1659 <        final Noop r = new Noop();
1659 >        final FailingRunnable r1 = new FailingRunnable(m);
1660 >        final FailingRunnable r2 = new FailingRunnable(m);
1661  
1662 <        assertTrue(g.cancel(mayInterruptIfRunning));
1663 <        f.complete(v1);
1664 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1662 >        CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r1);
1663 >        if (fFirst) {
1664 >            f.complete(v1);
1665 >            g.complete(v2);
1666 >        } else {
1667 >            g.complete(v2);
1668 >            f.complete(v1);
1669 >        }
1670 >        CompletableFuture<Void> h2 = m.runAfterBoth(f, g, r2);
1671  
1672 <        checkCompletedWithWrappedCancellationException(h);
1673 <        checkCancelled(g);
2027 <        assertEquals(0, r.invocationCount);
1672 >        checkCompletedWithWrappedCFException(h1);
1673 >        checkCompletedWithWrappedCFException(h2);
1674          checkCompletedNormally(f, v1);
1675 <    }}
2030 <
2031 <    public void testRunAfterBoth_sourceCancelled4() {
2032 <        for (ExecutionMode m : ExecutionMode.values())
2033 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
2034 <        for (Integer v1 : new Integer[] { 1, null })
2035 <    {
2036 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2037 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2038 <        final Noop r = new Noop();
2039 <
2040 <        assertTrue(f.cancel(mayInterruptIfRunning));
2041 <        g.complete(v1);
2042 <        final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
2043 <
2044 <        checkCompletedWithWrappedCancellationException(h);
2045 <        checkCancelled(f);
2046 <        assertEquals(0, r.invocationCount);
2047 <        checkCompletedNormally(g, v1);
1675 >        checkCompletedNormally(g, v2);
1676      }}
1677  
1678      /**
1679       * applyToEither result completes normally after normal completion
1680       * of either source
1681       */
1682 <    public void testApplyToEither_normalCompletion1() {
1682 >    public void testApplyToEither_normalCompletion() {
1683          for (ExecutionMode m : ExecutionMode.values())
1684          for (Integer v1 : new Integer[] { 1, null })
1685          for (Integer v2 : new Integer[] { 2, null })
1686      {
1687          final CompletableFuture<Integer> f = new CompletableFuture<>();
1688          final CompletableFuture<Integer> g = new CompletableFuture<>();
1689 <        final IncFunction r = new IncFunction();
1690 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1689 >        final IncFunction[] rs = new IncFunction[6];
1690 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1691  
1692 +        final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]);
1693 +        final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]);
1694 +        checkIncomplete(h0);
1695 +        checkIncomplete(h1);
1696 +        rs[0].assertNotInvoked();
1697 +        rs[1].assertNotInvoked();
1698          f.complete(v1);
1699 <        checkCompletedNormally(h, inc(v1));
1699 >        checkCompletedNormally(h0, inc(v1));
1700 >        checkCompletedNormally(h1, inc(v1));
1701 >        final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]);
1702 >        final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]);
1703 >        checkCompletedNormally(h2, inc(v1));
1704 >        checkCompletedNormally(h3, inc(v1));
1705          g.complete(v2);
1706  
1707 <        checkCompletedNormally(f, v1);
1708 <        checkCompletedNormally(g, v2);
1709 <        checkCompletedNormally(h, inc(v1));
1710 <    }}
1711 <
1712 <    public void testApplyToEither_normalCompletion2() {
1713 <        for (ExecutionMode m : ExecutionMode.values())
1714 <        for (Integer v1 : new Integer[] { 1, null })
1715 <        for (Integer v2 : new Integer[] { 2, null })
2077 <    {
2078 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2079 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2080 <        final IncFunction r = new IncFunction();
2081 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2082 <
2083 <        g.complete(v2);
2084 <        checkCompletedNormally(h, inc(v2));
2085 <        f.complete(v1);
1707 >        // unspecified behavior - both source completions available
1708 >        final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]);
1709 >        final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]);
1710 >        rs[4].assertValue(h4.join());
1711 >        rs[5].assertValue(h5.join());
1712 >        assertTrue(Objects.equals(inc(v1), h4.join()) ||
1713 >                   Objects.equals(inc(v2), h4.join()));
1714 >        assertTrue(Objects.equals(inc(v1), h5.join()) ||
1715 >                   Objects.equals(inc(v2), h5.join()));
1716  
1717          checkCompletedNormally(f, v1);
1718          checkCompletedNormally(g, v2);
1719 <        checkCompletedNormally(h, inc(v2));
1720 <        }}
1721 <
1722 <    public void testApplyToEither_normalCompletion3() {
1723 <        for (ExecutionMode m : ExecutionMode.values())
2094 <        for (Integer v1 : new Integer[] { 1, null })
2095 <        for (Integer v2 : new Integer[] { 2, null })
2096 <    {
2097 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2098 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2099 <        final IncFunction r = new IncFunction();
2100 <
2101 <        f.complete(v1);
2102 <        g.complete(v2);
2103 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2104 <
2105 <        checkCompletedNormally(f, v1);
2106 <        checkCompletedNormally(g, v2);
2107 <
2108 <        // unspecified behavior
2109 <        assertTrue(Objects.equals(h.join(), inc(v1)) ||
2110 <                   Objects.equals(h.join(), inc(v2)));
2111 <        assertEquals(1, r.invocationCount);
1719 >        checkCompletedNormally(h0, inc(v1));
1720 >        checkCompletedNormally(h1, inc(v1));
1721 >        checkCompletedNormally(h2, inc(v1));
1722 >        checkCompletedNormally(h3, inc(v1));
1723 >        for (int i = 0; i < 4; i++) rs[i].assertValue(inc(v1));
1724      }}
1725  
1726      /**
1727       * applyToEither result completes exceptionally after exceptional
1728       * completion of either source
1729       */
1730 <    public void testApplyToEither_exceptionalCompletion1() {
1730 >    public void testApplyToEither_exceptionalCompletion() {
1731          for (ExecutionMode m : ExecutionMode.values())
1732          for (Integer v1 : new Integer[] { 1, null })
1733      {
1734          final CompletableFuture<Integer> f = new CompletableFuture<>();
1735          final CompletableFuture<Integer> g = new CompletableFuture<>();
2124        final IncFunction r = new IncFunction();
2125        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1736          final CFException ex = new CFException();
1737 +        final IncFunction[] rs = new IncFunction[6];
1738 +        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1739  
1740 +        final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]);
1741 +        final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]);
1742 +        checkIncomplete(h0);
1743 +        checkIncomplete(h1);
1744 +        rs[0].assertNotInvoked();
1745 +        rs[1].assertNotInvoked();
1746          f.completeExceptionally(ex);
1747 <        checkCompletedWithWrappedCFException(h, ex);
1747 >        checkCompletedWithWrappedCFException(h0, ex);
1748 >        checkCompletedWithWrappedCFException(h1, ex);
1749 >        final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]);
1750 >        final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]);
1751 >        checkCompletedWithWrappedCFException(h2, ex);
1752 >        checkCompletedWithWrappedCFException(h3, ex);
1753          g.complete(v1);
1754  
1755 <        assertEquals(0, r.invocationCount);
1756 <        checkCompletedNormally(g, v1);
1757 <        checkCompletedWithWrappedCFException(f, ex);
2135 <        checkCompletedWithWrappedCFException(h, ex);
2136 <    }}
2137 <
2138 <    public void testApplyToEither_exceptionalCompletion2() {
2139 <        for (ExecutionMode m : ExecutionMode.values())
2140 <        for (Integer v1 : new Integer[] { 1, null })
2141 <    {
2142 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2143 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2144 <        final IncFunction r = new IncFunction();
2145 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2146 <        final CFException ex = new CFException();
2147 <
2148 <        g.completeExceptionally(ex);
2149 <        checkCompletedWithWrappedCFException(h, ex);
2150 <        f.complete(v1);
2151 <
2152 <        assertEquals(0, r.invocationCount);
2153 <        checkCompletedNormally(f, v1);
2154 <        checkCompletedWithWrappedCFException(g, ex);
2155 <        checkCompletedWithWrappedCFException(h, ex);
2156 <    }}
2157 <
2158 <    public void testApplyToEither_exceptionalCompletion3() {
2159 <        for (ExecutionMode m : ExecutionMode.values())
2160 <        for (Integer v1 : new Integer[] { 1, null })
2161 <    {
2162 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2163 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2164 <        final IncFunction r = new IncFunction();
2165 <        final CFException ex = new CFException();
2166 <
2167 <        g.completeExceptionally(ex);
2168 <        f.complete(v1);
2169 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2170 <
2171 <        // unspecified behavior
2172 <        Integer v;
1755 >        // unspecified behavior - both source completions available
1756 >        final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]);
1757 >        final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]);
1758          try {
1759 <            assertEquals(inc(v1), h.join());
1760 <            assertEquals(1, r.invocationCount);
1759 >            assertEquals(inc(v1), h4.join());
1760 >            rs[4].assertInvoked();
1761          } catch (CompletionException ok) {
1762 <            checkCompletedWithWrappedCFException(h, ex);
1763 <            assertEquals(0, r.invocationCount);
1762 >            checkCompletedWithWrappedCFException(h4, ex);
1763 >            rs[4].assertNotInvoked();
1764          }
2180
2181        checkCompletedWithWrappedCFException(g, ex);
2182        checkCompletedNormally(f, v1);
2183    }}
2184
2185    public void testApplyToEither_exceptionalCompletion4() {
2186        for (ExecutionMode m : ExecutionMode.values())
2187        for (Integer v1 : new Integer[] { 1, null })
2188    {
2189        final CompletableFuture<Integer> f = new CompletableFuture<>();
2190        final CompletableFuture<Integer> g = new CompletableFuture<>();
2191        final IncFunction r = new IncFunction();
2192        final CFException ex = new CFException();
2193
2194        f.completeExceptionally(ex);
2195        g.complete(v1);
2196        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2197
2198        // unspecified behavior
2199        Integer v;
1765          try {
1766 <            assertEquals(inc(v1), h.join());
1767 <            assertEquals(1, r.invocationCount);
1766 >            assertEquals(inc(v1), h5.join());
1767 >            rs[5].assertInvoked();
1768          } catch (CompletionException ok) {
1769 <            checkCompletedWithWrappedCFException(h, ex);
1770 <            assertEquals(0, r.invocationCount);
1769 >            checkCompletedWithWrappedCFException(h5, ex);
1770 >            rs[5].assertNotInvoked();
1771          }
1772  
1773          checkCompletedWithWrappedCFException(f, ex);
1774          checkCompletedNormally(g, v1);
1775 <    }}
1776 <
1777 <    /**
1778 <     * applyToEither result completes exceptionally if action does
1779 <     */
1780 <    public void testApplyToEither_actionFailed1() {
2216 <        for (ExecutionMode m : ExecutionMode.values())
2217 <        for (Integer v1 : new Integer[] { 1, null })
2218 <        for (Integer v2 : new Integer[] { 2, null })
2219 <    {
2220 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2221 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2222 <        final FailingFunction r = new FailingFunction();
2223 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2224 <
2225 <        f.complete(v1);
2226 <        checkCompletedWithWrappedCFException(h);
2227 <        g.complete(v2);
2228 <        checkCompletedNormally(f, v1);
2229 <        checkCompletedNormally(g, v2);
2230 <    }}
2231 <
2232 <    public void testApplyToEither_actionFailed2() {
2233 <        for (ExecutionMode m : ExecutionMode.values())
2234 <        for (Integer v1 : new Integer[] { 1, null })
2235 <        for (Integer v2 : new Integer[] { 2, null })
2236 <    {
2237 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2238 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2239 <        final FailingFunction r = new FailingFunction();
2240 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2241 <
2242 <        g.complete(v2);
2243 <        checkCompletedWithWrappedCFException(h);
2244 <        f.complete(v1);
2245 <        checkCompletedNormally(f, v1);
2246 <        checkCompletedNormally(g, v2);
1775 >        checkCompletedWithWrappedCFException(h0, ex);
1776 >        checkCompletedWithWrappedCFException(h1, ex);
1777 >        checkCompletedWithWrappedCFException(h2, ex);
1778 >        checkCompletedWithWrappedCFException(h3, ex);
1779 >        checkCompletedWithWrappedCFException(h4, ex);
1780 >        for (int i = 0; i < 4; i++) rs[i].assertNotInvoked();
1781      }}
1782  
1783      /**
1784       * applyToEither result completes exceptionally if either source cancelled
1785       */
1786 <    public void testApplyToEither_sourceCancelled1() {
1786 >    public void testApplyToEither_sourceCancelled() {
1787          for (ExecutionMode m : ExecutionMode.values())
1788          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1789          for (Integer v1 : new Integer[] { 1, null })
1790      {
1791          final CompletableFuture<Integer> f = new CompletableFuture<>();
1792          final CompletableFuture<Integer> g = new CompletableFuture<>();
1793 <        final IncFunction r = new IncFunction();
1794 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1793 >        final IncFunction[] rs = new IncFunction[6];
1794 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1795  
1796 <        assertTrue(f.cancel(mayInterruptIfRunning));
1797 <        checkCompletedWithWrappedCancellationException(h);
1796 >        final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]);
1797 >        final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]);
1798 >        checkIncomplete(h0);
1799 >        checkIncomplete(h1);
1800 >        rs[0].assertNotInvoked();
1801 >        rs[1].assertNotInvoked();
1802 >        f.cancel(mayInterruptIfRunning);
1803 >        checkCompletedWithWrappedCancellationException(h0);
1804 >        checkCompletedWithWrappedCancellationException(h1);
1805 >        final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]);
1806 >        final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]);
1807 >        checkCompletedWithWrappedCancellationException(h2);
1808 >        checkCompletedWithWrappedCancellationException(h3);
1809          g.complete(v1);
1810  
1811 <        checkCancelled(f);
1812 <        assertEquals(0, r.invocationCount);
1813 <        checkCompletedNormally(g, v1);
2269 <        checkCompletedWithWrappedCancellationException(h);
2270 <    }}
2271 <
2272 <    public void testApplyToEither_sourceCancelled2() {
2273 <        for (ExecutionMode m : ExecutionMode.values())
2274 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
2275 <        for (Integer v1 : new Integer[] { 1, null })
2276 <    {
2277 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2278 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2279 <        final IncFunction r = new IncFunction();
2280 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2281 <
2282 <        assertTrue(g.cancel(mayInterruptIfRunning));
2283 <        checkCompletedWithWrappedCancellationException(h);
2284 <        f.complete(v1);
2285 <
2286 <        checkCancelled(g);
2287 <        assertEquals(0, r.invocationCount);
2288 <        checkCompletedNormally(f, v1);
2289 <        checkCompletedWithWrappedCancellationException(h);
2290 <    }}
2291 <
2292 <    public void testApplyToEither_sourceCancelled3() {
2293 <        for (ExecutionMode m : ExecutionMode.values())
2294 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
2295 <        for (Integer v1 : new Integer[] { 1, null })
2296 <    {
2297 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
2298 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
2299 <        final IncFunction r = new IncFunction();
2300 <
2301 <        assertTrue(g.cancel(mayInterruptIfRunning));
2302 <        f.complete(v1);
2303 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
2304 <
2305 <        // unspecified behavior
2306 <        Integer v;
1811 >        // unspecified behavior - both source completions available
1812 >        final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]);
1813 >        final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]);
1814          try {
1815 <            assertEquals(inc(v1), h.join());
1816 <            assertEquals(1, r.invocationCount);
1815 >            assertEquals(inc(v1), h4.join());
1816 >            rs[4].assertInvoked();
1817          } catch (CompletionException ok) {
1818 <            checkCompletedWithWrappedCancellationException(h);
1819 <            assertEquals(0, r.invocationCount);
1818 >            checkCompletedWithWrappedCancellationException(h4);
1819 >            rs[4].assertNotInvoked();
1820 >        }
1821 >        try {
1822 >            assertEquals(inc(v1), h5.join());
1823 >            rs[5].assertInvoked();
1824 >        } catch (CompletionException ok) {
1825 >            checkCompletedWithWrappedCancellationException(h5);
1826 >            rs[5].assertNotInvoked();
1827          }
1828  
1829 <        checkCancelled(g);
1830 <        checkCompletedNormally(f, v1);
1829 >        checkCancelled(f);
1830 >        checkCompletedNormally(g, v1);
1831 >        checkCompletedWithWrappedCancellationException(h0);
1832 >        checkCompletedWithWrappedCancellationException(h1);
1833 >        checkCompletedWithWrappedCancellationException(h2);
1834 >        checkCompletedWithWrappedCancellationException(h3);
1835 >        for (int i = 0; i < 4; i++) rs[i].assertNotInvoked();
1836      }}
1837  
1838 <    public void testApplyToEither_sourceCancelled4() {
1838 >    /**
1839 >     * applyToEither result completes exceptionally if action does
1840 >     */
1841 >    public void testApplyToEither_actionFailed() {
1842          for (ExecutionMode m : ExecutionMode.values())
2321        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1843          for (Integer v1 : new Integer[] { 1, null })
1844 +        for (Integer v2 : new Integer[] { 2, null })
1845      {
1846          final CompletableFuture<Integer> f = new CompletableFuture<>();
1847          final CompletableFuture<Integer> g = new CompletableFuture<>();
1848 <        final IncFunction r = new IncFunction();
1848 >        final FailingFunction[] rs = new FailingFunction[6];
1849 >        for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m);
1850  
1851 <        assertTrue(f.cancel(mayInterruptIfRunning));
1852 <        g.complete(v1);
1853 <        final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1854 <
1855 <        // unspecified behavior
1856 <        Integer v;
1857 <        try {
1858 <            assertEquals(inc(v1), h.join());
1859 <            assertEquals(1, r.invocationCount);
1860 <        } catch (CompletionException ok) {
1861 <            checkCompletedWithWrappedCancellationException(h);
1862 <            assertEquals(0, r.invocationCount);
1863 <        }
1864 <
1865 <        checkCancelled(f);
1866 <        checkCompletedNormally(g, v1);
1851 >        final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]);
1852 >        final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]);
1853 >        f.complete(v1);
1854 >        final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]);
1855 >        final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]);
1856 >        g.complete(v2);
1857 >        final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]);
1858 >        final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]);
1859 >        
1860 >        checkCompletedNormally(f, v1);
1861 >        checkCompletedNormally(g, v2);
1862 >        checkCompletedWithWrappedCFException(h0);
1863 >        checkCompletedWithWrappedCFException(h1);
1864 >        checkCompletedWithWrappedCFException(h2);
1865 >        checkCompletedWithWrappedCFException(h3);
1866 >        checkCompletedWithWrappedCFException(h4);
1867 >        checkCompletedWithWrappedCFException(h5);
1868 >        for (int i = 0; i < rs.length; i++) rs[i].assertInvoked();
1869      }}
1870  
1871      /**
# Line 2354 | Line 1879 | public class CompletableFutureTest exten
1879      {
1880          final CompletableFuture<Integer> f = new CompletableFuture<>();
1881          final CompletableFuture<Integer> g = new CompletableFuture<>();
1882 <        final IncAction r = new IncAction();
1882 >        final IncAction r = new IncAction(m);
1883          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
1884  
1885          f.complete(v1);
# Line 2374 | Line 1899 | public class CompletableFutureTest exten
1899      {
1900          final CompletableFuture<Integer> f = new CompletableFuture<>();
1901          final CompletableFuture<Integer> g = new CompletableFuture<>();
1902 <        final IncAction r = new IncAction();
1902 >        final IncAction r = new IncAction(m);
1903          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
1904  
1905          g.complete(v2);
# Line 2394 | Line 1919 | public class CompletableFutureTest exten
1919      {
1920          final CompletableFuture<Integer> f = new CompletableFuture<>();
1921          final CompletableFuture<Integer> g = new CompletableFuture<>();
1922 <        final IncAction r = new IncAction();
1922 >        final IncAction r = new IncAction(m);
1923  
1924          f.complete(v1);
1925          g.complete(v2);
# Line 2419 | Line 1944 | public class CompletableFutureTest exten
1944      {
1945          final CompletableFuture<Integer> f = new CompletableFuture<>();
1946          final CompletableFuture<Integer> g = new CompletableFuture<>();
1947 <        final IncAction r = new IncAction();
1947 >        final IncAction r = new IncAction(m);
1948          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
1949          final CFException ex = new CFException();
1950  
# Line 2427 | Line 1952 | public class CompletableFutureTest exten
1952          checkCompletedWithWrappedCFException(h, ex);
1953          g.complete(v1);
1954  
1955 <        assertEquals(0, r.invocationCount);
1955 >        r.assertNotInvoked();
1956          checkCompletedNormally(g, v1);
1957          checkCompletedWithWrappedCFException(f, ex);
1958          checkCompletedWithWrappedCFException(h, ex);
# Line 2439 | Line 1964 | public class CompletableFutureTest exten
1964      {
1965          final CompletableFuture<Integer> f = new CompletableFuture<>();
1966          final CompletableFuture<Integer> g = new CompletableFuture<>();
1967 <        final IncAction r = new IncAction();
1967 >        final IncAction r = new IncAction(m);
1968          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
1969          final CFException ex = new CFException();
1970  
# Line 2447 | Line 1972 | public class CompletableFutureTest exten
1972          checkCompletedWithWrappedCFException(h, ex);
1973          f.complete(v1);
1974  
1975 <        assertEquals(0, r.invocationCount);
1975 >        r.assertNotInvoked();
1976          checkCompletedNormally(f, v1);
1977          checkCompletedWithWrappedCFException(g, ex);
1978          checkCompletedWithWrappedCFException(h, ex);
# Line 2459 | Line 1984 | public class CompletableFutureTest exten
1984      {
1985          final CompletableFuture<Integer> f = new CompletableFuture<>();
1986          final CompletableFuture<Integer> g = new CompletableFuture<>();
1987 <        final IncAction r = new IncAction();
1987 >        final IncAction r = new IncAction(m);
1988          final CFException ex = new CFException();
1989  
1990          g.completeExceptionally(ex);
# Line 2470 | Line 1995 | public class CompletableFutureTest exten
1995          Integer v;
1996          try {
1997              assertNull(h.join());
1998 <            assertEquals(1, r.invocationCount);
1998 >            r.assertInvoked();
1999              assertEquals(inc(v1), r.value);
2000          } catch (CompletionException ok) {
2001              checkCompletedWithWrappedCFException(h, ex);
2002 <            assertEquals(0, r.invocationCount);
2002 >            r.assertNotInvoked();
2003          }
2004  
2005          checkCompletedWithWrappedCFException(g, ex);
# Line 2487 | Line 2012 | public class CompletableFutureTest exten
2012      {
2013          final CompletableFuture<Integer> f = new CompletableFuture<>();
2014          final CompletableFuture<Integer> g = new CompletableFuture<>();
2015 <        final IncAction r = new IncAction();
2015 >        final IncAction r = new IncAction(m);
2016          final CFException ex = new CFException();
2017  
2018          f.completeExceptionally(ex);
# Line 2498 | Line 2023 | public class CompletableFutureTest exten
2023          Integer v;
2024          try {
2025              assertNull(h.join());
2026 <            assertEquals(1, r.invocationCount);
2026 >            r.assertInvoked();
2027              assertEquals(inc(v1), r.value);
2028          } catch (CompletionException ok) {
2029              checkCompletedWithWrappedCFException(h, ex);
2030 <            assertEquals(0, r.invocationCount);
2030 >            r.assertNotInvoked();
2031          }
2032  
2033          checkCompletedWithWrappedCFException(f, ex);
# Line 2519 | Line 2044 | public class CompletableFutureTest exten
2044      {
2045          final CompletableFuture<Integer> f = new CompletableFuture<>();
2046          final CompletableFuture<Integer> g = new CompletableFuture<>();
2047 <        final FailingConsumer r = new FailingConsumer();
2047 >        final FailingConsumer r = new FailingConsumer(m);
2048          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2049  
2050          f.complete(v1);
# Line 2536 | Line 2061 | public class CompletableFutureTest exten
2061      {
2062          final CompletableFuture<Integer> f = new CompletableFuture<>();
2063          final CompletableFuture<Integer> g = new CompletableFuture<>();
2064 <        final FailingConsumer r = new FailingConsumer();
2064 >        final FailingConsumer r = new FailingConsumer(m);
2065          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2066  
2067          g.complete(v2);
# Line 2556 | Line 2081 | public class CompletableFutureTest exten
2081      {
2082          final CompletableFuture<Integer> f = new CompletableFuture<>();
2083          final CompletableFuture<Integer> g = new CompletableFuture<>();
2084 <        final IncAction r = new IncAction();
2084 >        final IncAction r = new IncAction(m);
2085          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2086  
2087          assertTrue(f.cancel(mayInterruptIfRunning));
# Line 2564 | Line 2089 | public class CompletableFutureTest exten
2089          g.complete(v1);
2090  
2091          checkCancelled(f);
2092 <        assertEquals(0, r.invocationCount);
2092 >        r.assertNotInvoked();
2093          checkCompletedNormally(g, v1);
2094          checkCompletedWithWrappedCancellationException(h);
2095      }}
# Line 2576 | Line 2101 | public class CompletableFutureTest exten
2101      {
2102          final CompletableFuture<Integer> f = new CompletableFuture<>();
2103          final CompletableFuture<Integer> g = new CompletableFuture<>();
2104 <        final IncAction r = new IncAction();
2104 >        final IncAction r = new IncAction(m);
2105          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2106  
2107          assertTrue(g.cancel(mayInterruptIfRunning));
# Line 2584 | Line 2109 | public class CompletableFutureTest exten
2109          f.complete(v1);
2110  
2111          checkCancelled(g);
2112 <        assertEquals(0, r.invocationCount);
2112 >        r.assertNotInvoked();
2113          checkCompletedNormally(f, v1);
2114          checkCompletedWithWrappedCancellationException(h);
2115      }}
# Line 2596 | Line 2121 | public class CompletableFutureTest exten
2121      {
2122          final CompletableFuture<Integer> f = new CompletableFuture<>();
2123          final CompletableFuture<Integer> g = new CompletableFuture<>();
2124 <        final IncAction r = new IncAction();
2124 >        final IncAction r = new IncAction(m);
2125  
2126          assertTrue(g.cancel(mayInterruptIfRunning));
2127          f.complete(v1);
# Line 2606 | Line 2131 | public class CompletableFutureTest exten
2131          Integer v;
2132          try {
2133              assertNull(h.join());
2134 <            assertEquals(1, r.invocationCount);
2134 >            r.assertInvoked();
2135              assertEquals(inc(v1), r.value);
2136          } catch (CompletionException ok) {
2137              checkCompletedWithWrappedCancellationException(h);
2138 <            assertEquals(0, r.invocationCount);
2138 >            r.assertNotInvoked();
2139          }
2140  
2141          checkCancelled(g);
# Line 2624 | Line 2149 | public class CompletableFutureTest exten
2149      {
2150          final CompletableFuture<Integer> f = new CompletableFuture<>();
2151          final CompletableFuture<Integer> g = new CompletableFuture<>();
2152 <        final IncAction r = new IncAction();
2152 >        final IncAction r = new IncAction(m);
2153  
2154          assertTrue(f.cancel(mayInterruptIfRunning));
2155          g.complete(v1);
# Line 2634 | Line 2159 | public class CompletableFutureTest exten
2159          Integer v;
2160          try {
2161              assertNull(h.join());
2162 <            assertEquals(1, r.invocationCount);
2162 >            r.assertInvoked();
2163              assertEquals(inc(v1), r.value);
2164          } catch (CompletionException ok) {
2165              checkCompletedWithWrappedCancellationException(h);
2166 <            assertEquals(0, r.invocationCount);
2166 >            r.assertNotInvoked();
2167          }
2168  
2169          checkCancelled(f);
# Line 2656 | Line 2181 | public class CompletableFutureTest exten
2181      {
2182          final CompletableFuture<Integer> f = new CompletableFuture<>();
2183          final CompletableFuture<Integer> g = new CompletableFuture<>();
2184 <        final Noop r = new Noop();
2184 >        final Noop r = new Noop(m);
2185          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2186  
2187          f.complete(v1);
2188          checkCompletedNormally(h, null);
2189 <        assertEquals(1, r.invocationCount);
2189 >        r.assertInvoked();
2190          g.complete(v2);
2191  
2192          checkCompletedNormally(f, v1);
2193          checkCompletedNormally(g, v2);
2194          checkCompletedNormally(h, null);
2195 <        assertEquals(1, r.invocationCount);
2195 >        r.assertInvoked();
2196      }}
2197  
2198      public void testRunAfterEither_normalCompletion2() {
# Line 2677 | Line 2202 | public class CompletableFutureTest exten
2202      {
2203          final CompletableFuture<Integer> f = new CompletableFuture<>();
2204          final CompletableFuture<Integer> g = new CompletableFuture<>();
2205 <        final Noop r = new Noop();
2205 >        final Noop r = new Noop(m);
2206          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2207  
2208          g.complete(v2);
2209          checkCompletedNormally(h, null);
2210 <        assertEquals(1, r.invocationCount);
2210 >        r.assertInvoked();
2211          f.complete(v1);
2212  
2213          checkCompletedNormally(f, v1);
2214          checkCompletedNormally(g, v2);
2215          checkCompletedNormally(h, null);
2216 <        assertEquals(1, r.invocationCount);
2216 >        r.assertInvoked();
2217          }}
2218  
2219      public void testRunAfterEither_normalCompletion3() {
# Line 2698 | Line 2223 | public class CompletableFutureTest exten
2223      {
2224          final CompletableFuture<Integer> f = new CompletableFuture<>();
2225          final CompletableFuture<Integer> g = new CompletableFuture<>();
2226 <        final Noop r = new Noop();
2226 >        final Noop r = new Noop(m);
2227  
2228          f.complete(v1);
2229          g.complete(v2);
# Line 2707 | Line 2232 | public class CompletableFutureTest exten
2232          checkCompletedNormally(h, null);
2233          checkCompletedNormally(f, v1);
2234          checkCompletedNormally(g, v2);
2235 <        assertEquals(1, r.invocationCount);
2235 >        r.assertInvoked();
2236      }}
2237  
2238      /**
# Line 2720 | Line 2245 | public class CompletableFutureTest exten
2245      {
2246          final CompletableFuture<Integer> f = new CompletableFuture<>();
2247          final CompletableFuture<Integer> g = new CompletableFuture<>();
2248 <        final Noop r = new Noop();
2248 >        final Noop r = new Noop(m);
2249          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2250          final CFException ex = new CFException();
2251  
# Line 2728 | Line 2253 | public class CompletableFutureTest exten
2253          checkCompletedWithWrappedCFException(h, ex);
2254          g.complete(v1);
2255  
2256 <        assertEquals(0, r.invocationCount);
2256 >        r.assertNotInvoked();
2257          checkCompletedNormally(g, v1);
2258          checkCompletedWithWrappedCFException(f, ex);
2259          checkCompletedWithWrappedCFException(h, ex);
# Line 2740 | Line 2265 | public class CompletableFutureTest exten
2265      {
2266          final CompletableFuture<Integer> f = new CompletableFuture<>();
2267          final CompletableFuture<Integer> g = new CompletableFuture<>();
2268 <        final Noop r = new Noop();
2268 >        final Noop r = new Noop(m);
2269          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2270          final CFException ex = new CFException();
2271  
# Line 2748 | Line 2273 | public class CompletableFutureTest exten
2273          checkCompletedWithWrappedCFException(h, ex);
2274          f.complete(v1);
2275  
2276 <        assertEquals(0, r.invocationCount);
2276 >        r.assertNotInvoked();
2277          checkCompletedNormally(f, v1);
2278          checkCompletedWithWrappedCFException(g, ex);
2279          checkCompletedWithWrappedCFException(h, ex);
# Line 2760 | Line 2285 | public class CompletableFutureTest exten
2285      {
2286          final CompletableFuture<Integer> f = new CompletableFuture<>();
2287          final CompletableFuture<Integer> g = new CompletableFuture<>();
2288 <        final Noop r = new Noop();
2288 >        final Noop r = new Noop(m);
2289          final CFException ex = new CFException();
2290  
2291          g.completeExceptionally(ex);
# Line 2771 | Line 2296 | public class CompletableFutureTest exten
2296          Integer v;
2297          try {
2298              assertNull(h.join());
2299 <            assertEquals(1, r.invocationCount);
2299 >            r.assertInvoked();
2300          } catch (CompletionException ok) {
2301              checkCompletedWithWrappedCFException(h, ex);
2302 <            assertEquals(0, r.invocationCount);
2302 >            r.assertNotInvoked();
2303          }
2304  
2305          checkCompletedWithWrappedCFException(g, ex);
# Line 2787 | Line 2312 | public class CompletableFutureTest exten
2312      {
2313          final CompletableFuture<Integer> f = new CompletableFuture<>();
2314          final CompletableFuture<Integer> g = new CompletableFuture<>();
2315 <        final Noop r = new Noop();
2315 >        final Noop r = new Noop(m);
2316          final CFException ex = new CFException();
2317  
2318          f.completeExceptionally(ex);
# Line 2798 | Line 2323 | public class CompletableFutureTest exten
2323          Integer v;
2324          try {
2325              assertNull(h.join());
2326 <            assertEquals(1, r.invocationCount);
2326 >            r.assertInvoked();
2327          } catch (CompletionException ok) {
2328              checkCompletedWithWrappedCFException(h, ex);
2329 <            assertEquals(0, r.invocationCount);
2329 >            r.assertNotInvoked();
2330          }
2331  
2332          checkCompletedWithWrappedCFException(f, ex);
# Line 2818 | Line 2343 | public class CompletableFutureTest exten
2343      {
2344          final CompletableFuture<Integer> f = new CompletableFuture<>();
2345          final CompletableFuture<Integer> g = new CompletableFuture<>();
2346 <        final FailingRunnable r = new FailingRunnable();
2346 >        final FailingRunnable r = new FailingRunnable(m);
2347          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2348  
2349          f.complete(v1);
# Line 2835 | Line 2360 | public class CompletableFutureTest exten
2360      {
2361          final CompletableFuture<Integer> f = new CompletableFuture<>();
2362          final CompletableFuture<Integer> g = new CompletableFuture<>();
2363 <        final FailingRunnable r = new FailingRunnable();
2363 >        final FailingRunnable r = new FailingRunnable(m);
2364          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2365  
2366          g.complete(v2);
# Line 2855 | Line 2380 | public class CompletableFutureTest exten
2380      {
2381          final CompletableFuture<Integer> f = new CompletableFuture<>();
2382          final CompletableFuture<Integer> g = new CompletableFuture<>();
2383 <        final Noop r = new Noop();
2383 >        final Noop r = new Noop(m);
2384          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2385  
2386          assertTrue(f.cancel(mayInterruptIfRunning));
# Line 2863 | Line 2388 | public class CompletableFutureTest exten
2388          g.complete(v1);
2389  
2390          checkCancelled(f);
2391 <        assertEquals(0, r.invocationCount);
2391 >        r.assertNotInvoked();
2392          checkCompletedNormally(g, v1);
2393          checkCompletedWithWrappedCancellationException(h);
2394      }}
# Line 2875 | Line 2400 | public class CompletableFutureTest exten
2400      {
2401          final CompletableFuture<Integer> f = new CompletableFuture<>();
2402          final CompletableFuture<Integer> g = new CompletableFuture<>();
2403 <        final Noop r = new Noop();
2403 >        final Noop r = new Noop(m);
2404          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2405  
2406          assertTrue(g.cancel(mayInterruptIfRunning));
# Line 2883 | Line 2408 | public class CompletableFutureTest exten
2408          f.complete(v1);
2409  
2410          checkCancelled(g);
2411 <        assertEquals(0, r.invocationCount);
2411 >        r.assertNotInvoked();
2412          checkCompletedNormally(f, v1);
2413          checkCompletedWithWrappedCancellationException(h);
2414      }}
# Line 2895 | Line 2420 | public class CompletableFutureTest exten
2420      {
2421          final CompletableFuture<Integer> f = new CompletableFuture<>();
2422          final CompletableFuture<Integer> g = new CompletableFuture<>();
2423 <        final Noop r = new Noop();
2423 >        final Noop r = new Noop(m);
2424  
2425          assertTrue(g.cancel(mayInterruptIfRunning));
2426          f.complete(v1);
# Line 2905 | Line 2430 | public class CompletableFutureTest exten
2430          Integer v;
2431          try {
2432              assertNull(h.join());
2433 <            assertEquals(1, r.invocationCount);
2433 >            r.assertInvoked();
2434          } catch (CompletionException ok) {
2435              checkCompletedWithWrappedCancellationException(h);
2436 <            assertEquals(0, r.invocationCount);
2436 >            r.assertNotInvoked();
2437          }
2438  
2439          checkCancelled(g);
# Line 2922 | Line 2447 | public class CompletableFutureTest exten
2447      {
2448          final CompletableFuture<Integer> f = new CompletableFuture<>();
2449          final CompletableFuture<Integer> g = new CompletableFuture<>();
2450 <        final Noop r = new Noop();
2450 >        final Noop r = new Noop(m);
2451  
2452          assertTrue(f.cancel(mayInterruptIfRunning));
2453          g.complete(v1);
# Line 2932 | Line 2457 | public class CompletableFutureTest exten
2457          Integer v;
2458          try {
2459              assertNull(h.join());
2460 <            assertEquals(1, r.invocationCount);
2460 >            r.assertInvoked();
2461          } catch (CompletionException ok) {
2462              checkCompletedWithWrappedCancellationException(h);
2463 <            assertEquals(0, r.invocationCount);
2463 >            r.assertNotInvoked();
2464          }
2465  
2466          checkCancelled(f);
# Line 2951 | Line 2476 | public class CompletableFutureTest exten
2476          for (Integer v1 : new Integer[] { 1, null })
2477      {
2478          final CompletableFuture<Integer> f = new CompletableFuture<>();
2479 <        final CompletableFutureInc r = new CompletableFutureInc();
2479 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2480          if (!createIncomplete) f.complete(v1);
2481 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2481 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2482          if (createIncomplete) f.complete(v1);
2483  
2484          checkCompletedNormally(g, inc(v1));
2485          checkCompletedNormally(f, v1);
2486 <        assertEquals(1, r.invocationCount);
2486 >        r.assertInvoked();
2487      }}
2488  
2489      /**
# Line 2970 | Line 2495 | public class CompletableFutureTest exten
2495          for (boolean createIncomplete : new boolean[] { true, false })
2496      {
2497          final CFException ex = new CFException();
2498 <        final CompletableFutureInc r = new CompletableFutureInc();
2498 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2499          final CompletableFuture<Integer> f = new CompletableFuture<>();
2500          if (!createIncomplete) f.completeExceptionally(ex);
2501 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2501 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2502          if (createIncomplete) f.completeExceptionally(ex);
2503  
2504          checkCompletedWithWrappedCFException(g, ex);
2505          checkCompletedWithWrappedCFException(f, ex);
2506 <        assertEquals(0, r.invocationCount);
2506 >        r.assertNotInvoked();
2507      }}
2508  
2509      /**
# Line 2991 | Line 2516 | public class CompletableFutureTest exten
2516      {
2517          final CompletableFuture<Integer> f = new CompletableFuture<>();
2518          final FailingCompletableFutureFunction r
2519 <            = new FailingCompletableFutureFunction();
2519 >            = new FailingCompletableFutureFunction(m);
2520          if (!createIncomplete) f.complete(v1);
2521 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2521 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2522          if (createIncomplete) f.complete(v1);
2523  
2524          checkCompletedWithWrappedCFException(g);
# Line 3009 | Line 2534 | public class CompletableFutureTest exten
2534          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
2535      {
2536          final CompletableFuture<Integer> f = new CompletableFuture<>();
2537 <        final CompletableFutureInc r = new CompletableFutureInc();
2537 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2538          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
2539 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2539 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2540          if (createIncomplete) {
2541              checkIncomplete(g);
2542              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 3038 | Line 2563 | public class CompletableFutureTest exten
2563       */
2564      public void testAllOf_normal() throws Exception {
2565          for (int k = 1; k < 20; ++k) {
2566 <            CompletableFuture<Integer>[] fs = (CompletableFuture<Integer>[]) new CompletableFuture[k];
2566 >            CompletableFuture<Integer>[] fs
2567 >                = (CompletableFuture<Integer>[]) new CompletableFuture[k];
2568              for (int i = 0; i < k; ++i)
2569                  fs[i] = new CompletableFuture<>();
2570              CompletableFuture<Void> f = CompletableFuture.allOf(fs);
# Line 3052 | Line 2578 | public class CompletableFutureTest exten
2578          }
2579      }
2580  
2581 +    public void testAllOf_backwards() throws Exception {
2582 +        for (int k = 1; k < 20; ++k) {
2583 +            CompletableFuture<Integer>[] fs
2584 +                = (CompletableFuture<Integer>[]) new CompletableFuture[k];
2585 +            for (int i = 0; i < k; ++i)
2586 +                fs[i] = new CompletableFuture<>();
2587 +            CompletableFuture<Void> f = CompletableFuture.allOf(fs);
2588 +            for (int i = k - 1; i >= 0; i--) {
2589 +                checkIncomplete(f);
2590 +                checkIncomplete(CompletableFuture.allOf(fs));
2591 +                fs[i].complete(one);
2592 +            }
2593 +            checkCompletedNormally(f, null);
2594 +            checkCompletedNormally(CompletableFuture.allOf(fs), null);
2595 +        }
2596 +    }
2597 +
2598      /**
2599       * anyOf(no component futures) returns an incomplete future
2600       */
# Line 3110 | Line 2653 | public class CompletableFutureTest exten
2653          Runnable[] throwingActions = {
2654              () -> CompletableFuture.supplyAsync(null),
2655              () -> CompletableFuture.supplyAsync(null, exec),
2656 <            () -> CompletableFuture.supplyAsync(supplyOne, null),
2656 >            () -> CompletableFuture.supplyAsync(new IntegerSupplier(ExecutionMode.DEFAULT, 42), null),
2657  
2658              () -> CompletableFuture.runAsync(null),
2659              () -> CompletableFuture.runAsync(null, exec),
# Line 3183 | Line 2726 | public class CompletableFutureTest exten
2726  
2727              () -> f.thenCompose(null),
2728              () -> f.thenComposeAsync(null),
2729 <            () -> f.thenComposeAsync(new CompletableFutureInc(), null),
2729 >            () -> f.thenComposeAsync(new CompletableFutureInc(ExecutionMode.EXECUTOR), null),
2730              () -> f.thenComposeAsync(null, exec),
2731  
2732              () -> f.exceptionally(null),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines