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.218 by jsr166, Sat Nov 24 18:24:14 2018 UTC vs.
Revision 1.223 by jsr166, Mon Dec 16 22:36:39 2019 UTC

# Line 926 | Line 926 | public class CompletableFutureTest exten
926          for (boolean createIncomplete : new boolean[] { true, false })
927          for (Integer v1 : new Integer[] { 1, null })
928      {
929 +        final AtomicInteger ran = new AtomicInteger(0);
930          final CompletableFuture<Integer> f = new CompletableFuture<>();
931          if (!createIncomplete) assertTrue(f.complete(v1));
932          final CompletableFuture<Integer> g = m.exceptionally
933              (f, (Throwable t) -> {
934 <                threadFail("should not be called");
935 <                return null;            // unreached
934 >                ran.getAndIncrement();
935 >                throw new AssertionError("should not be called");
936              });
937          if (createIncomplete) assertTrue(f.complete(v1));
938  
939          checkCompletedNormally(g, v1);
940          checkCompletedNormally(f, v1);
941 +        assertEquals(0, ran.get());
942      }}
943  
944      /**
# Line 3436 | Line 3438 | public class CompletableFutureTest exten
3438          CompletableFuture<Integer> nullFuture = (CompletableFuture<Integer>)null;
3439          ThreadExecutor exec = new ThreadExecutor();
3440  
3441 <        Runnable[] throwingActions = {
3441 >        assertThrows(
3442 >            NullPointerException.class,
3443 >
3444              () -> CompletableFuture.supplyAsync(null),
3445              () -> CompletableFuture.supplyAsync(null, exec),
3446              () -> CompletableFuture.supplyAsync(new IntegerSupplier(ExecutionMode.SYNC, 42), null),
# Line 3539 | Line 3543 | public class CompletableFutureTest exten
3543              () -> f.completeOnTimeout(42, 1L, null),
3544  
3545              () -> CompletableFuture.failedFuture(null),
3546 <            () -> CompletableFuture.failedStage(null),
3543 <        };
3546 >            () -> CompletableFuture.failedStage(null));
3547  
3545        assertThrows(NullPointerException.class, throwingActions);
3548          assertEquals(0, exec.count.get());
3549      }
3550  
# Line 3750 | Line 3752 | public class CompletableFutureTest exten
3752      }
3753  
3754      /**
3753     * failedFuture(null) throws NPE
3754     */
3755    public void testFailedFuture_null() {
3756        try {
3757            CompletableFuture<Integer> f = CompletableFuture.failedFuture(null);
3758            shouldThrow();
3759        } catch (NullPointerException success) {}
3760    }
3761
3762    /**
3755       * copy returns a CompletableFuture that is completed normally,
3756       * with the same value, when source is.
3757       */
# Line 4188 | Line 4180 | public class CompletableFutureTest exten
4180              // Manufacture boxed primitives for primitive params
4181              for (int i = 0; i < args.length; i++) {
4182                  Class<?> type = parameterTypes[i];
4183 <                if (parameterTypes[i] == boolean.class)
4184 <                    args[i] = false;
4185 <                else if (parameterTypes[i] == int.class)
4194 <                    args[i] = 0;
4195 <                else if (parameterTypes[i] == long.class)
4196 <                    args[i] = 0L;
4183 >                if      (type == boolean.class) args[i] = false;
4184 >                else if (type == int.class)     args[i] = 0;
4185 >                else if (type == long.class)    args[i] = 0L;
4186              }
4187              for (CompletionStage<Integer> stage : stages) {
4188                  try {
# Line 4829 | Line 4818 | public class CompletableFutureTest exten
4818          for (boolean createIncomplete : new boolean[] { true, false })
4819          for (Integer v1 : new Integer[] { 1, null })
4820      {
4821 +        final AtomicInteger ran = new AtomicInteger(0);
4822          final CompletableFuture<Integer> f = new CompletableFuture<>();
4823          final DelegatedCompletionStage<Integer> d =
4824              new DelegatedCompletionStage<Integer>(f);
4825          if (!createIncomplete) assertTrue(f.complete(v1));
4826          final CompletionStage<Integer> g = d.exceptionallyAsync
4827              ((Throwable t) -> {
4828 <                threadFail("should not be called");
4829 <                return null;            // unreached
4828 >                ran.getAndIncrement();
4829 >                throw new AssertionError("should not be called");
4830              });
4831          if (createIncomplete) assertTrue(f.complete(v1));
4832  
4833          checkCompletedNormally(g.toCompletableFuture(), v1);
4834 +        checkCompletedNormally(f, v1);
4835 +        assertEquals(0, ran.get());
4836      }}
4837  
4838      /**
# Line 4866 | Line 4858 | public class CompletableFutureTest exten
4858          if (createIncomplete) f.completeExceptionally(ex);
4859  
4860          checkCompletedNormally(g.toCompletableFuture(), v1);
4861 +        checkCompletedExceptionally(f, ex);
4862          assertEquals(1, ran.get());
4863      }}
4864  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines