3118 |
|
assertSame(f, f.toCompletableFuture()); |
3119 |
|
} |
3120 |
|
|
3121 |
+ |
//--- tests of implementation details; not part of official tck --- |
3122 |
+ |
|
3123 |
+ |
Object resultOf(CompletableFuture<?> f) { |
3124 |
+ |
try { |
3125 |
+ |
java.lang.reflect.Field resultField |
3126 |
+ |
= CompletableFuture.class.getDeclaredField("result"); |
3127 |
+ |
resultField.setAccessible(true); |
3128 |
+ |
return resultField.get(f); |
3129 |
+ |
} catch (Throwable t) { throw new AssertionError(t); } |
3130 |
+ |
} |
3131 |
+ |
|
3132 |
+ |
public void testExceptionPropagationReusesResultObject() { |
3133 |
+ |
if (!testImplementationDetails) return; |
3134 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
3135 |
+ |
{ |
3136 |
+ |
final CompletableFuture<Void> f = new CompletableFuture<>(); |
3137 |
+ |
CFException ex = new CFException(); |
3138 |
+ |
f.completeExceptionally(ex); |
3139 |
+ |
final CompletableFuture<Void> g = f.thenRun(new Noop(m)); |
3140 |
+ |
checkCompletedWithWrappedException(g, ex); |
3141 |
+ |
final CompletableFuture<Void> h = g.thenRun(new Noop(m)); |
3142 |
+ |
checkCompletedWithWrappedException(h, ex); |
3143 |
+ |
assertSame(resultOf(g), resultOf(h)); |
3144 |
+ |
}} |
3145 |
+ |
|
3146 |
|
// public void testRunAfterEither_resultDeterminedAtTimeOfCreation() { |
3147 |
|
// for (ExecutionMode m : ExecutionMode.values()) |
3148 |
|
// for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |