--- jsr166/src/test/tck/ForkJoinTaskTest.java 2017/05/29 19:15:02 1.52 +++ jsr166/src/test/tck/ForkJoinTaskTest.java 2017/10/21 06:52:36 1.54 @@ -8,6 +8,7 @@ import static java.util.concurrent.TimeU import java.util.Arrays; import java.util.HashSet; +import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; @@ -115,7 +116,7 @@ public class ForkJoinTaskTest extends JS try { assertSame(expected, a.get()); assertSame(expected, a.get(randomTimeout(), randomTimeUnit())); - } catch (Throwable fail) { threadUnexpectedException(fail); } + } catch (Exception fail) { threadUnexpectedException(fail); } } void checkCancelled(ForkJoinTask a) { @@ -1648,4 +1649,42 @@ public class ForkJoinTaskTest extends JS testInvokeOnPool(mainPool(), a); } + /** + * adapt(runnable).toString() contains toString of wrapped task + */ + public void testAdapt_Runnable_toString() { + if (testImplementationDetails) { + Runnable r = () -> {}; + ForkJoinTask task = ForkJoinTask.adapt(r); + assertEquals( + identityString(task) + "[Wrapped task = " + r.toString() + "]", + task.toString()); + } + } + + /** + * adapt(runnable, x).toString() contains toString of wrapped task + */ + public void testAdapt_Runnable_withResult_toString() { + if (testImplementationDetails) { + Runnable r = () -> {}; + ForkJoinTask task = ForkJoinTask.adapt(r, ""); + assertEquals( + identityString(task) + "[Wrapped task = " + r.toString() + "]", + task.toString()); + } + } + + /** + * adapt(callable).toString() contains toString of wrapped task + */ + public void testAdapt_Callable_toString() { + if (testImplementationDetails) { + Callable c = () -> ""; + ForkJoinTask task = ForkJoinTask.adapt(c); + assertEquals( + identityString(task) + "[Wrapped task = " + c.toString() + "]", + task.toString()); + } + } }