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.90 by jsr166, Tue Jun 17 18:09:28 2014 UTC vs.
Revision 1.98 by jsr166, Wed Dec 31 19:05:42 2014 UTC

# Line 5 | Line 5
5   * http://creativecommons.org/publicdomain/zero/1.0/
6   */
7  
8 < import junit.framework.*;
8 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
9 > import static java.util.concurrent.TimeUnit.SECONDS;
10 >
11 > import java.util.ArrayList;
12 > import java.util.List;
13 > import java.util.Objects;
14   import java.util.concurrent.Callable;
10 import java.util.concurrent.Executor;
11 import java.util.concurrent.ExecutorService;
12 import java.util.concurrent.Executors;
15   import java.util.concurrent.CancellationException;
14 import java.util.concurrent.CountDownLatch;
15 import java.util.concurrent.ExecutionException;
16 import java.util.concurrent.Future;
16   import java.util.concurrent.CompletableFuture;
17   import java.util.concurrent.CompletionException;
18   import java.util.concurrent.CompletionStage;
19 + import java.util.concurrent.ExecutionException;
20 + import java.util.concurrent.Executor;
21   import java.util.concurrent.ForkJoinPool;
22   import java.util.concurrent.ForkJoinTask;
23   import java.util.concurrent.TimeoutException;
24   import java.util.concurrent.atomic.AtomicInteger;
24 import static java.util.concurrent.TimeUnit.MILLISECONDS;
25 import static java.util.concurrent.TimeUnit.SECONDS;
26 import java.util.*;
27 import java.util.function.Supplier;
28 import java.util.function.Consumer;
25   import java.util.function.BiConsumer;
30 import java.util.function.Function;
26   import java.util.function.BiFunction;
27 + import java.util.function.Consumer;
28 + import java.util.function.Function;
29 + import java.util.function.Supplier;
30 +
31 + import junit.framework.Test;
32 + import junit.framework.TestSuite;
33  
34   public class CompletableFutureTest extends JSR166TestCase {
35  
# Line 57 | Line 58 | public class CompletableFutureTest exten
58      }
59  
60      <T> void checkCompletedNormally(CompletableFuture<T> f, T value) {
61 <        try {
62 <            assertEquals(value, f.get(LONG_DELAY_MS, MILLISECONDS));
62 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
61 >        checkTimedGet(f, value);
62 >
63          try {
64              assertEquals(value, f.join());
65          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 76 | Line 76 | public class CompletableFutureTest exten
76      }
77  
78      void checkCompletedWithWrappedCFException(CompletableFuture<?> f) {
79 +        long startTime = System.nanoTime();
80 +        long timeoutMillis = LONG_DELAY_MS;
81          try {
82 <            f.get(LONG_DELAY_MS, MILLISECONDS);
82 >            f.get(timeoutMillis, MILLISECONDS);
83              shouldThrow();
84          } catch (ExecutionException success) {
85              assertTrue(success.getCause() instanceof CFException);
86          } catch (Throwable fail) { threadUnexpectedException(fail); }
87 +        assertTrue(millisElapsedSince(startTime) < timeoutMillis/2);
88 +
89          try {
90              f.join();
91              shouldThrow();
# Line 107 | Line 111 | public class CompletableFutureTest exten
111  
112      <U> void checkCompletedExceptionallyWithRootCause(CompletableFuture<U> f,
113                                                        Throwable ex) {
114 +        long startTime = System.nanoTime();
115 +        long timeoutMillis = LONG_DELAY_MS;
116          try {
117 <            f.get(LONG_DELAY_MS, MILLISECONDS);
117 >            f.get(timeoutMillis, MILLISECONDS);
118              shouldThrow();
119          } catch (ExecutionException success) {
120              assertSame(ex, success.getCause());
121          } catch (Throwable fail) { threadUnexpectedException(fail); }
122 +        assertTrue(millisElapsedSince(startTime) < timeoutMillis/2);
123 +
124          try {
125              f.join();
126              shouldThrow();
# Line 158 | Line 166 | public class CompletableFutureTest exten
166      }
167  
168      void checkCancelled(CompletableFuture<?> f) {
169 +        long startTime = System.nanoTime();
170 +        long timeoutMillis = LONG_DELAY_MS;
171          try {
172 <            f.get(LONG_DELAY_MS, MILLISECONDS);
172 >            f.get(timeoutMillis, MILLISECONDS);
173              shouldThrow();
174          } catch (CancellationException success) {
175          } catch (Throwable fail) { threadUnexpectedException(fail); }
176 +        assertTrue(millisElapsedSince(startTime) < timeoutMillis/2);
177 +
178          try {
179              f.join();
180              shouldThrow();
# Line 183 | Line 195 | public class CompletableFutureTest exten
195      }
196  
197      void checkCompletedWithWrappedCancellationException(CompletableFuture<?> f) {
198 +        long startTime = System.nanoTime();
199 +        long timeoutMillis = LONG_DELAY_MS;
200          try {
201 <            f.get(LONG_DELAY_MS, MILLISECONDS);
201 >            f.get(timeoutMillis, MILLISECONDS);
202              shouldThrow();
203          } catch (ExecutionException success) {
204              assertTrue(success.getCause() instanceof CancellationException);
205          } catch (Throwable fail) { threadUnexpectedException(fail); }
206 +        assertTrue(millisElapsedSince(startTime) < timeoutMillis/2);
207 +
208          try {
209              f.join();
210              shouldThrow();
# Line 569 | Line 585 | public class CompletableFutureTest exten
585          }
586      }
587  
588 +    static final boolean defaultExecutorIsCommonPool
589 +        = ForkJoinPool.getCommonPoolParallelism() > 1;
590 +
591      /**
592       * Permits the testing of parallel code for the 3 different
593       * execution modes without copy/pasting all the test methods.
594       */
595      enum ExecutionMode {
596 <        DEFAULT {
596 >        SYNC {
597              public void checkExecutionMode() {
598                  assertFalse(ThreadExecutor.startedCurrentThread());
599                  assertNull(ForkJoinTask.getPool());
# Line 650 | Line 669 | public class CompletableFutureTest exten
669  
670          ASYNC {
671              public void checkExecutionMode() {
672 <                assertSame(ForkJoinPool.commonPool(),
673 <                           ForkJoinTask.getPool());
672 >                assertEquals(defaultExecutorIsCommonPool,
673 >                             (ForkJoinPool.commonPool() == ForkJoinTask.getPool()));
674              }
675              public CompletableFuture<Void> runAsync(Runnable a) {
676                  return CompletableFuture.runAsync(a);
# Line 875 | Line 894 | public class CompletableFutureTest exten
894          if (!createIncomplete) f.completeExceptionally(ex);
895          final CompletableFuture<Integer> g = f.exceptionally
896              ((Throwable t) -> {
897 <                ExecutionMode.DEFAULT.checkExecutionMode();
897 >                ExecutionMode.SYNC.checkExecutionMode();
898                  threadAssertSame(t, ex);
899                  a.getAndIncrement();
900                  return v1;
# Line 897 | Line 916 | public class CompletableFutureTest exten
916          if (!createIncomplete) f.completeExceptionally(ex1);
917          final CompletableFuture<Integer> g = f.exceptionally
918              ((Throwable t) -> {
919 <                ExecutionMode.DEFAULT.checkExecutionMode();
919 >                ExecutionMode.SYNC.checkExecutionMode();
920                  threadAssertSame(t, ex1);
921                  a.getAndIncrement();
922                  throw ex2;
# Line 1370 | Line 1389 | public class CompletableFutureTest exten
1389          final CompletableFuture<Void> h0 = m.thenRun(f, rs[0]);
1390          final CompletableFuture<Void> h1 = m.runAfterBoth(f, f, rs[1]);
1391          final CompletableFuture<Void> h2 = m.runAfterEither(f, f, rs[2]);
1373        final FailingRunnable r = new FailingRunnable(m);
1392          assertTrue(f.complete(v1));
1393          final CompletableFuture<Void> h3 = m.thenRun(f, rs[3]);
1394          final CompletableFuture<Void> h4 = m.runAfterBoth(f, f, rs[4]);
# Line 1390 | Line 1408 | public class CompletableFutureTest exten
1408       */
1409      public void testThenApply_normalCompletion() {
1410          for (ExecutionMode m : ExecutionMode.values())
1393        for (boolean createIncomplete : new boolean[] { true, false })
1411          for (Integer v1 : new Integer[] { 1, null })
1412      {
1413          final CompletableFuture<Integer> f = new CompletableFuture<>();
1414 <        final IncFunction r = new IncFunction(m);
1415 <        if (!createIncomplete) assertTrue(f.complete(v1));
1399 <        final CompletableFuture<Integer> g = m.thenApply(f, r);
1400 <        if (createIncomplete) {
1401 <            checkIncomplete(g);
1402 <            assertTrue(f.complete(v1));
1403 <        }
1414 >        final IncFunction[] rs = new IncFunction[4];
1415 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1416  
1417 <        checkCompletedNormally(g, inc(v1));
1417 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1418 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1419 >        checkIncomplete(h0);
1420 >        checkIncomplete(h1);
1421 >        assertTrue(f.complete(v1));
1422 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1423 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1424 >
1425 >        checkCompletedNormally(h0, inc(v1));
1426 >        checkCompletedNormally(h1, inc(v1));
1427 >        checkCompletedNormally(h2, inc(v1));
1428 >        checkCompletedNormally(h3, inc(v1));
1429          checkCompletedNormally(f, v1);
1430 <        r.assertValue(inc(v1));
1430 >        for (IncFunction r : rs) r.assertValue(inc(v1));
1431      }}
1432  
1433      /**
# Line 1413 | Line 1436 | public class CompletableFutureTest exten
1436       */
1437      public void testThenApply_exceptionalCompletion() {
1438          for (ExecutionMode m : ExecutionMode.values())
1416        for (boolean createIncomplete : new boolean[] { true, false })
1439      {
1440          final CFException ex = new CFException();
1441          final CompletableFuture<Integer> f = new CompletableFuture<>();
1442 <        final IncFunction r = new IncFunction(m);
1443 <        if (!createIncomplete) f.completeExceptionally(ex);
1422 <        final CompletableFuture<Integer> g = m.thenApply(f, r);
1423 <        if (createIncomplete) {
1424 <            checkIncomplete(g);
1425 <            f.completeExceptionally(ex);
1426 <        }
1442 >        final IncFunction[] rs = new IncFunction[4];
1443 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1444  
1445 <        checkCompletedWithWrappedException(g, ex);
1445 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1446 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1447 >        assertTrue(f.completeExceptionally(ex));
1448 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1449 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1450 >
1451 >        checkCompletedWithWrappedException(h0, ex);
1452 >        checkCompletedWithWrappedException(h1, ex);
1453 >        checkCompletedWithWrappedException(h2, ex);
1454 >        checkCompletedWithWrappedException(h3, ex);
1455          checkCompletedExceptionally(f, ex);
1456 <        r.assertNotInvoked();
1456 >        for (IncFunction r : rs) r.assertNotInvoked();
1457      }}
1458  
1459      /**
# Line 1435 | Line 1461 | public class CompletableFutureTest exten
1461       */
1462      public void testThenApply_sourceCancelled() {
1463          for (ExecutionMode m : ExecutionMode.values())
1438        for (boolean createIncomplete : new boolean[] { true, false })
1464          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1465      {
1466          final CompletableFuture<Integer> f = new CompletableFuture<>();
1467 <        final IncFunction r = new IncFunction(m);
1468 <        if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1444 <        final CompletableFuture<Integer> g = m.thenApply(f, r);
1445 <        if (createIncomplete) {
1446 <            checkIncomplete(g);
1447 <            assertTrue(f.cancel(mayInterruptIfRunning));
1448 <        }
1467 >        final IncFunction[] rs = new IncFunction[4];
1468 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1469  
1470 <        checkCompletedWithWrappedCancellationException(g);
1470 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1471 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1472 >        assertTrue(f.cancel(mayInterruptIfRunning));
1473 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1474 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1475 >
1476 >        checkCompletedWithWrappedCancellationException(h0);
1477 >        checkCompletedWithWrappedCancellationException(h1);
1478 >        checkCompletedWithWrappedCancellationException(h2);
1479 >        checkCompletedWithWrappedCancellationException(h3);
1480          checkCancelled(f);
1481 <        r.assertNotInvoked();
1481 >        for (IncFunction r : rs) r.assertNotInvoked();
1482      }}
1483  
1484      /**
# Line 1457 | Line 1486 | public class CompletableFutureTest exten
1486       */
1487      public void testThenApply_actionFailed() {
1488          for (ExecutionMode m : ExecutionMode.values())
1460        for (boolean createIncomplete : new boolean[] { true, false })
1489          for (Integer v1 : new Integer[] { 1, null })
1490      {
1491          final CompletableFuture<Integer> f = new CompletableFuture<>();
1492 <        final FailingFunction r = new FailingFunction(m);
1493 <        if (!createIncomplete) assertTrue(f.complete(v1));
1466 <        final CompletableFuture<Integer> g = m.thenApply(f, r);
1467 <        if (createIncomplete) {
1468 <            checkIncomplete(g);
1469 <            assertTrue(f.complete(v1));
1470 <        }
1492 >        final FailingFunction[] rs = new FailingFunction[4];
1493 >        for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m);
1494  
1495 <        checkCompletedWithWrappedCFException(g);
1495 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1496 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1497 >        assertTrue(f.complete(v1));
1498 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1499 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1500 >
1501 >        checkCompletedWithWrappedCFException(h0);
1502 >        checkCompletedWithWrappedCFException(h1);
1503 >        checkCompletedWithWrappedCFException(h2);
1504 >        checkCompletedWithWrappedCFException(h3);
1505          checkCompletedNormally(f, v1);
1506      }}
1507  
# Line 1478 | Line 1510 | public class CompletableFutureTest exten
1510       */
1511      public void testThenAccept_normalCompletion() {
1512          for (ExecutionMode m : ExecutionMode.values())
1481        for (boolean createIncomplete : new boolean[] { true, false })
1513          for (Integer v1 : new Integer[] { 1, null })
1514      {
1515          final CompletableFuture<Integer> f = new CompletableFuture<>();
1516 <        final NoopConsumer r = new NoopConsumer(m);
1517 <        if (!createIncomplete) assertTrue(f.complete(v1));
1487 <        final CompletableFuture<Void> g = m.thenAccept(f, r);
1488 <        if (createIncomplete) {
1489 <            checkIncomplete(g);
1490 <            assertTrue(f.complete(v1));
1491 <        }
1516 >        final NoopConsumer[] rs = new NoopConsumer[4];
1517 >        for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m);
1518  
1519 <        checkCompletedNormally(g, null);
1520 <        r.assertValue(v1);
1519 >        final CompletableFuture<Void> h0 = m.thenAccept(f, rs[0]);
1520 >        final CompletableFuture<Void> h1 = m.acceptEither(f, f, rs[1]);
1521 >        checkIncomplete(h0);
1522 >        checkIncomplete(h1);
1523 >        assertTrue(f.complete(v1));
1524 >        final CompletableFuture<Void> h2 = m.thenAccept(f, rs[2]);
1525 >        final CompletableFuture<Void> h3 = m.acceptEither(f, f, rs[3]);
1526 >
1527 >        checkCompletedNormally(h0, null);
1528 >        checkCompletedNormally(h1, null);
1529 >        checkCompletedNormally(h2, null);
1530 >        checkCompletedNormally(h3, null);
1531          checkCompletedNormally(f, v1);
1532 +        for (NoopConsumer r : rs) r.assertValue(v1);
1533      }}
1534  
1535      /**
# Line 1501 | Line 1538 | public class CompletableFutureTest exten
1538       */
1539      public void testThenAccept_exceptionalCompletion() {
1540          for (ExecutionMode m : ExecutionMode.values())
1504        for (boolean createIncomplete : new boolean[] { true, false })
1541      {
1542          final CFException ex = new CFException();
1543          final CompletableFuture<Integer> f = new CompletableFuture<>();
1544 <        final NoopConsumer r = new NoopConsumer(m);
1545 <        if (!createIncomplete) f.completeExceptionally(ex);
1510 <        final CompletableFuture<Void> g = m.thenAccept(f, r);
1511 <        if (createIncomplete) {
1512 <            checkIncomplete(g);
1513 <            f.completeExceptionally(ex);
1514 <        }
1544 >        final NoopConsumer[] rs = new NoopConsumer[4];
1545 >        for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m);
1546  
1547 <        checkCompletedWithWrappedException(g, ex);
1547 >        final CompletableFuture<Void> h0 = m.thenAccept(f, rs[0]);
1548 >        final CompletableFuture<Void> h1 = m.acceptEither(f, f, rs[1]);
1549 >        assertTrue(f.completeExceptionally(ex));
1550 >        final CompletableFuture<Void> h2 = m.thenAccept(f, rs[2]);
1551 >        final CompletableFuture<Void> h3 = m.acceptEither(f, f, rs[3]);
1552 >
1553 >        checkCompletedWithWrappedException(h0, ex);
1554 >        checkCompletedWithWrappedException(h1, ex);
1555 >        checkCompletedWithWrappedException(h2, ex);
1556 >        checkCompletedWithWrappedException(h3, ex);
1557          checkCompletedExceptionally(f, ex);
1558 <        r.assertNotInvoked();
1558 >        for (NoopConsumer r : rs) r.assertNotInvoked();
1559      }}
1560  
1561      /**
# Line 1523 | Line 1563 | public class CompletableFutureTest exten
1563       */
1564      public void testThenAccept_sourceCancelled() {
1565          for (ExecutionMode m : ExecutionMode.values())
1526        for (boolean createIncomplete : new boolean[] { true, false })
1566          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1567      {
1568          final CompletableFuture<Integer> f = new CompletableFuture<>();
1569 <        final NoopConsumer r = new NoopConsumer(m);
1570 <        if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1532 <        final CompletableFuture<Void> g = m.thenAccept(f, r);
1533 <        if (createIncomplete) {
1534 <            checkIncomplete(g);
1535 <            assertTrue(f.cancel(mayInterruptIfRunning));
1536 <        }
1569 >        final NoopConsumer[] rs = new NoopConsumer[4];
1570 >        for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m);
1571  
1572 <        checkCompletedWithWrappedCancellationException(g);
1572 >        final CompletableFuture<Void> h0 = m.thenAccept(f, rs[0]);
1573 >        final CompletableFuture<Void> h1 = m.acceptEither(f, f, rs[1]);
1574 >        assertTrue(f.cancel(mayInterruptIfRunning));
1575 >        final CompletableFuture<Void> h2 = m.thenAccept(f, rs[2]);
1576 >        final CompletableFuture<Void> h3 = m.acceptEither(f, f, rs[3]);
1577 >
1578 >        checkCompletedWithWrappedCancellationException(h0);
1579 >        checkCompletedWithWrappedCancellationException(h1);
1580 >        checkCompletedWithWrappedCancellationException(h2);
1581 >        checkCompletedWithWrappedCancellationException(h3);
1582          checkCancelled(f);
1583 <        r.assertNotInvoked();
1583 >        for (NoopConsumer r : rs) r.assertNotInvoked();
1584      }}
1585  
1586      /**
# Line 1545 | Line 1588 | public class CompletableFutureTest exten
1588       */
1589      public void testThenAccept_actionFailed() {
1590          for (ExecutionMode m : ExecutionMode.values())
1548        for (boolean createIncomplete : new boolean[] { true, false })
1591          for (Integer v1 : new Integer[] { 1, null })
1592      {
1593          final CompletableFuture<Integer> f = new CompletableFuture<>();
1594 <        final FailingConsumer r = new FailingConsumer(m);
1595 <        if (!createIncomplete) f.complete(v1);
1554 <        final CompletableFuture<Void> g = m.thenAccept(f, r);
1555 <        if (createIncomplete) {
1556 <            checkIncomplete(g);
1557 <            f.complete(v1);
1558 <        }
1594 >        final FailingConsumer[] rs = new FailingConsumer[4];
1595 >        for (int i = 0; i < rs.length; i++) rs[i] = new FailingConsumer(m);
1596  
1597 <        checkCompletedWithWrappedCFException(g);
1597 >        final CompletableFuture<Void> h0 = m.thenAccept(f, rs[0]);
1598 >        final CompletableFuture<Void> h1 = m.acceptEither(f, f, rs[1]);
1599 >        assertTrue(f.complete(v1));
1600 >        final CompletableFuture<Void> h2 = m.thenAccept(f, rs[2]);
1601 >        final CompletableFuture<Void> h3 = m.acceptEither(f, f, rs[3]);
1602 >
1603 >        checkCompletedWithWrappedCFException(h0);
1604 >        checkCompletedWithWrappedCFException(h1);
1605 >        checkCompletedWithWrappedCFException(h2);
1606 >        checkCompletedWithWrappedCFException(h3);
1607          checkCompletedNormally(f, v1);
1608      }}
1609  
# Line 1573 | Line 1619 | public class CompletableFutureTest exten
1619      {
1620          final CompletableFuture<Integer> f = new CompletableFuture<>();
1621          final CompletableFuture<Integer> g = new CompletableFuture<>();
1622 <        final SubtractFunction r1 = new SubtractFunction(m);
1623 <        final SubtractFunction r2 = new SubtractFunction(m);
1578 <        final SubtractFunction r3 = new SubtractFunction(m);
1622 >        final SubtractFunction[] rs = new SubtractFunction[6];
1623 >        for (int i = 0; i < rs.length; i++) rs[i] = new SubtractFunction(m);
1624  
1625          final CompletableFuture<Integer> fst =  fFirst ? f : g;
1626          final CompletableFuture<Integer> snd = !fFirst ? f : g;
1627          final Integer w1 =  fFirst ? v1 : v2;
1628          final Integer w2 = !fFirst ? v1 : v2;
1629  
1630 <        final CompletableFuture<Integer> h1 = m.thenCombine(f, g, r1);
1630 >        final CompletableFuture<Integer> h0 = m.thenCombine(f, g, rs[0]);
1631 >        final CompletableFuture<Integer> h1 = m.thenCombine(fst, fst, rs[1]);
1632          assertTrue(fst.complete(w1));
1633 <        final CompletableFuture<Integer> h2 = m.thenCombine(f, g, r2);
1634 <        checkIncomplete(h1);
1635 <        checkIncomplete(h2);
1636 <        r1.assertNotInvoked();
1637 <        r2.assertNotInvoked();
1633 >        final CompletableFuture<Integer> h2 = m.thenCombine(f, g, rs[2]);
1634 >        final CompletableFuture<Integer> h3 = m.thenCombine(fst, fst, rs[3]);
1635 >        checkIncomplete(h0); rs[0].assertNotInvoked();
1636 >        checkIncomplete(h2); rs[2].assertNotInvoked();
1637 >        checkCompletedNormally(h1, subtract(w1, w1));
1638 >        checkCompletedNormally(h3, subtract(w1, w1));
1639 >        rs[1].assertValue(subtract(w1, w1));
1640 >        rs[3].assertValue(subtract(w1, w1));
1641          assertTrue(snd.complete(w2));
1642 <        final CompletableFuture<Integer> h3 = m.thenCombine(f, g, r3);
1642 >        final CompletableFuture<Integer> h4 = m.thenCombine(f, g, rs[4]);
1643  
1644 <        checkCompletedNormally(h1, subtract(v1, v2));
1644 >        checkCompletedNormally(h0, subtract(v1, v2));
1645          checkCompletedNormally(h2, subtract(v1, v2));
1646 <        checkCompletedNormally(h3, subtract(v1, v2));
1647 <        r1.assertValue(subtract(v1, v2));
1648 <        r2.assertValue(subtract(v1, v2));
1649 <        r3.assertValue(subtract(v1, v2));
1646 >        checkCompletedNormally(h4, subtract(v1, v2));
1647 >        rs[0].assertValue(subtract(v1, v2));
1648 >        rs[2].assertValue(subtract(v1, v2));
1649 >        rs[4].assertValue(subtract(v1, v2));
1650 >
1651          checkCompletedNormally(f, v1);
1652          checkCompletedNormally(g, v2);
1653      }}
# Line 3117 | Line 3167 | public class CompletableFutureTest exten
3167          Runnable[] throwingActions = {
3168              () -> CompletableFuture.supplyAsync(null),
3169              () -> CompletableFuture.supplyAsync(null, exec),
3170 <            () -> CompletableFuture.supplyAsync(new IntegerSupplier(ExecutionMode.DEFAULT, 42), null),
3170 >            () -> CompletableFuture.supplyAsync(new IntegerSupplier(ExecutionMode.SYNC, 42), null),
3171  
3172              () -> CompletableFuture.runAsync(null),
3173              () -> CompletableFuture.runAsync(null, exec),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines