320 |
|
checkCompletedNormally(f, "test"); |
321 |
|
} |
322 |
|
|
323 |
– |
// Choose non-commutative actions for better coverage |
324 |
– |
|
325 |
– |
// A non-commutative function that handles and produces null values as well. |
326 |
– |
static Integer subtract(Integer x, Integer y) { |
327 |
– |
return (x == null && y == null) ? null : |
328 |
– |
((x == null) ? 42 : x.intValue()) |
329 |
– |
- ((y == null) ? 99 : y.intValue()); |
330 |
– |
} |
331 |
– |
|
332 |
– |
// A function that handles and produces null values as well. |
333 |
– |
static Integer inc(Integer x) { |
334 |
– |
return (x == null) ? null : x + 1; |
335 |
– |
} |
336 |
– |
|
323 |
|
static final class IntegerSupplier implements Supplier<Integer> { |
324 |
|
final ExecutionMode m; |
325 |
|
int invocationCount = 0; |
334 |
|
return value; |
335 |
|
} |
336 |
|
} |
337 |
< |
|
337 |
> |
|
338 |
> |
// A function that handles and produces null values as well. |
339 |
> |
static Integer inc(Integer x) { |
340 |
> |
return (x == null) ? null : x + 1; |
341 |
> |
} |
342 |
> |
|
343 |
|
static final class IncAction implements Consumer<Integer> { |
344 |
|
int invocationCount = 0; |
345 |
|
Integer value; |
359 |
|
return value = inc(x); |
360 |
|
} |
361 |
|
} |
362 |
+ |
|
363 |
+ |
// Choose non-commutative actions for better coverage |
364 |
+ |
// A non-commutative function that handles and produces null values as well. |
365 |
+ |
static Integer subtract(Integer x, Integer y) { |
366 |
+ |
return (x == null && y == null) ? null : |
367 |
+ |
((x == null) ? 42 : x.intValue()) |
368 |
+ |
- ((y == null) ? 99 : y.intValue()); |
369 |
+ |
} |
370 |
+ |
|
371 |
|
static final class SubtractAction implements BiConsumer<Integer, Integer> { |
372 |
|
final ExecutionMode m; |
373 |
|
int invocationCount = 0; |
392 |
|
return value = subtract(x, y); |
393 |
|
} |
394 |
|
} |
395 |
+ |
|
396 |
|
static final class Noop implements Runnable { |
397 |
|
final ExecutionMode m; |
398 |
|
int invocationCount = 0; |
506 |
|
|
507 |
|
/** |
508 |
|
* Permits the testing of parallel code for the 3 different |
509 |
< |
* execution modes without repeating all the testing code. |
509 |
> |
* execution modes without copy/pasting all the test methods. |
510 |
|
*/ |
511 |
|
enum ExecutionMode { |
512 |
|
DEFAULT { |
513 |
|
public void checkExecutionMode() { |
514 |
+ |
assertFalse(ThreadExecutor.startedCurrentThread()); |
515 |
|
assertNull(ForkJoinTask.getPool()); |
516 |
|
} |
517 |
|
public CompletableFuture<Void> runAsync(Runnable a) { |