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.91 by jsr166, Tue Jun 17 20:34:18 2014 UTC

# Line 1370 | Line 1370 | public class CompletableFutureTest exten
1370          final CompletableFuture<Void> h0 = m.thenRun(f, rs[0]);
1371          final CompletableFuture<Void> h1 = m.runAfterBoth(f, f, rs[1]);
1372          final CompletableFuture<Void> h2 = m.runAfterEither(f, f, rs[2]);
1373        final FailingRunnable r = new FailingRunnable(m);
1373          assertTrue(f.complete(v1));
1374          final CompletableFuture<Void> h3 = m.thenRun(f, rs[3]);
1375          final CompletableFuture<Void> h4 = m.runAfterBoth(f, f, rs[4]);
# Line 1390 | Line 1389 | public class CompletableFutureTest exten
1389       */
1390      public void testThenApply_normalCompletion() {
1391          for (ExecutionMode m : ExecutionMode.values())
1393        for (boolean createIncomplete : new boolean[] { true, false })
1392          for (Integer v1 : new Integer[] { 1, null })
1393      {
1394          final CompletableFuture<Integer> f = new CompletableFuture<>();
1395 <        final IncFunction r = new IncFunction(m);
1396 <        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 <        }
1395 >        final IncFunction[] rs = new IncFunction[4];
1396 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1397  
1398 <        checkCompletedNormally(g, inc(v1));
1398 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1399 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1400 >        checkIncomplete(h0);
1401 >        checkIncomplete(h1);
1402 >        assertTrue(f.complete(v1));
1403 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1404 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1405 >
1406 >        checkCompletedNormally(h0, inc(v1));
1407 >        checkCompletedNormally(h1, inc(v1));
1408 >        checkCompletedNormally(h2, inc(v1));
1409 >        checkCompletedNormally(h3, inc(v1));
1410          checkCompletedNormally(f, v1);
1411 <        r.assertValue(inc(v1));
1411 >        for (IncFunction r : rs) r.assertValue(inc(v1));
1412      }}
1413  
1414      /**
# Line 1413 | Line 1417 | public class CompletableFutureTest exten
1417       */
1418      public void testThenApply_exceptionalCompletion() {
1419          for (ExecutionMode m : ExecutionMode.values())
1416        for (boolean createIncomplete : new boolean[] { true, false })
1420      {
1421          final CFException ex = new CFException();
1422          final CompletableFuture<Integer> f = new CompletableFuture<>();
1423 <        final IncFunction r = new IncFunction(m);
1424 <        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 <        }
1423 >        final IncFunction[] rs = new IncFunction[4];
1424 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1425  
1426 <        checkCompletedWithWrappedException(g, ex);
1426 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1427 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1428 >        assertTrue(f.completeExceptionally(ex));
1429 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1430 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1431 >
1432 >        checkCompletedWithWrappedException(h0, ex);
1433 >        checkCompletedWithWrappedException(h1, ex);
1434 >        checkCompletedWithWrappedException(h2, ex);
1435 >        checkCompletedWithWrappedException(h3, ex);
1436          checkCompletedExceptionally(f, ex);
1437 <        r.assertNotInvoked();
1437 >        for (IncFunction r : rs) r.assertNotInvoked();
1438      }}
1439  
1440      /**
# Line 1435 | Line 1442 | public class CompletableFutureTest exten
1442       */
1443      public void testThenApply_sourceCancelled() {
1444          for (ExecutionMode m : ExecutionMode.values())
1438        for (boolean createIncomplete : new boolean[] { true, false })
1445          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1446      {
1447          final CompletableFuture<Integer> f = new CompletableFuture<>();
1448 <        final IncFunction r = new IncFunction(m);
1449 <        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 <        }
1448 >        final IncFunction[] rs = new IncFunction[4];
1449 >        for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m);
1450  
1451 <        checkCompletedWithWrappedCancellationException(g);
1451 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1452 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1453 >        assertTrue(f.cancel(mayInterruptIfRunning));
1454 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1455 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1456 >
1457 >        checkCompletedWithWrappedCancellationException(h0);
1458 >        checkCompletedWithWrappedCancellationException(h1);
1459 >        checkCompletedWithWrappedCancellationException(h2);
1460 >        checkCompletedWithWrappedCancellationException(h3);
1461          checkCancelled(f);
1462 <        r.assertNotInvoked();
1462 >        for (IncFunction r : rs) r.assertNotInvoked();
1463      }}
1464  
1465      /**
# Line 1457 | Line 1467 | public class CompletableFutureTest exten
1467       */
1468      public void testThenApply_actionFailed() {
1469          for (ExecutionMode m : ExecutionMode.values())
1460        for (boolean createIncomplete : new boolean[] { true, false })
1470          for (Integer v1 : new Integer[] { 1, null })
1471      {
1472          final CompletableFuture<Integer> f = new CompletableFuture<>();
1473 <        final FailingFunction r = new FailingFunction(m);
1474 <        if (!createIncomplete) assertTrue(f.complete(v1));
1475 <        final CompletableFuture<Integer> g = m.thenApply(f, r);
1476 <        if (createIncomplete) {
1477 <            checkIncomplete(g);
1478 <            assertTrue(f.complete(v1));
1479 <        }
1473 >        final FailingFunction[] rs = new FailingFunction[4];
1474 >        for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m);
1475 >
1476 >        final CompletableFuture<Integer> h0 = m.thenApply(f, rs[0]);
1477 >        final CompletableFuture<Integer> h1 = m.applyToEither(f, f, rs[1]);
1478 >        assertTrue(f.complete(v1));
1479 >        final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1480 >        final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1481  
1482 <        checkCompletedWithWrappedCFException(g);
1482 >        checkCompletedWithWrappedCFException(h0);
1483 >        checkCompletedWithWrappedCFException(h1);
1484 >        checkCompletedWithWrappedCFException(h2);
1485 >        checkCompletedWithWrappedCFException(h3);
1486          checkCompletedNormally(f, v1);
1487      }}
1488  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines