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.190 by jsr166, Wed Nov 8 02:21:43 2017 UTC vs.
Revision 1.195 by jsr166, Sun Jul 22 20:09:31 2018 UTC

# Line 41 | Line 41 | import java.util.function.Function;
41   import java.util.function.Predicate;
42   import java.util.function.Supplier;
43  
44 import junit.framework.AssertionFailedError;
44   import junit.framework.Test;
45   import junit.framework.TestSuite;
46  
# Line 60 | Line 59 | public class CompletableFutureTest exten
59          assertFalse(f.isDone());
60          assertFalse(f.isCancelled());
61          assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]"));
62 +
63 +        Object result = null;
64          try {
65 <            assertNull(f.getNow(null));
65 >            result = f.getNow(null);
66          } catch (Throwable fail) { threadUnexpectedException(fail); }
67 +        assertNull(result);
68 +
69          try {
70              f.get(randomExpiredTimeout(), randomTimeUnit());
71              shouldThrow();
# Line 292 | Line 295 | public class CompletableFutureTest exten
295          }
296  
297          f = new CompletableFuture<>();
298 <        f.completeExceptionally(ex = new CFException());
298 >        f.completeExceptionally(new CFException());
299          f.obtrudeValue(v1);
300          checkCompletedNormally(f, v1);
301          f.obtrudeException(ex = new CFException());
# Line 330 | Line 333 | public class CompletableFutureTest exten
333       * toString indicates current completion state
334       */
335      public void testToString_incomplete() {
336 <        CompletableFuture<String> f = new CompletableFuture<String>();
336 >        CompletableFuture<String> f = new CompletableFuture<>();
337          assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]"));
338          if (testImplementationDetails)
339              assertEquals(identityString(f) + "[Not completed]",
# Line 338 | Line 341 | public class CompletableFutureTest exten
341      }
342  
343      public void testToString_normal() {
344 <        CompletableFuture<String> f = new CompletableFuture<String>();
344 >        CompletableFuture<String> f = new CompletableFuture<>();
345          assertTrue(f.complete("foo"));
346          assertTrue(f.toString().matches(".*\\[.*Completed normally.*\\]"));
347          if (testImplementationDetails)
# Line 347 | Line 350 | public class CompletableFutureTest exten
350      }
351  
352      public void testToString_exception() {
353 <        CompletableFuture<String> f = new CompletableFuture<String>();
353 >        CompletableFuture<String> f = new CompletableFuture<>();
354          assertTrue(f.completeExceptionally(new IndexOutOfBoundsException()));
355          assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]"));
356          if (testImplementationDetails)
# Line 357 | Line 360 | public class CompletableFutureTest exten
360  
361      public void testToString_cancelled() {
362          for (boolean mayInterruptIfRunning : new boolean[] { true, false }) {
363 <            CompletableFuture<String> f = new CompletableFuture<String>();
363 >            CompletableFuture<String> f = new CompletableFuture<>();
364              assertTrue(f.cancel(mayInterruptIfRunning));
365              assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]"));
366              if (testImplementationDetails)
# Line 4190 | Line 4193 | public class CompletableFutureTest exten
4193          static void assertZero(CompletableFuture<?> f) {
4194              try {
4195                  f.getNow(null);
4196 <                throw new AssertionFailedError("should throw");
4196 >                throw new AssertionError("should throw");
4197              } catch (CompletionException success) {
4198                  assertTrue(success.getCause() instanceof ZeroException);
4199              }
# Line 4389 | Line 4392 | public class CompletableFutureTest exten
4392              f.complete(null);
4393  
4394              f = new CompletableFuture<>();
4395 <            CompletableFuture.anyOf(new CompletableFuture<?>[] { f, incomplete });
4395 >            CompletableFuture.anyOf(f, incomplete);
4396              f.complete(null);
4397          }
4398  
# Line 4407 | Line 4410 | public class CompletableFutureTest exten
4410              f.complete(null);
4411  
4412              f = new CompletableFuture<>();
4413 <            CompletableFuture.anyOf(new CompletableFuture<?>[] { incomplete, f });
4413 >            CompletableFuture.anyOf(incomplete, f);
4414              f.complete(null);
4415          }
4416      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines