--- jsr166/src/test/tck/ForkJoinTaskTest.java 2010/11/21 07:45:00 1.23 +++ jsr166/src/test/tck/ForkJoinTaskTest.java 2010/11/21 19:06:53 1.24 @@ -10,8 +10,10 @@ import java.util.concurrent.ForkJoinTask import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.RecursiveAction; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; import java.util.HashSet; import junit.framework.*; @@ -50,6 +52,7 @@ public class ForkJoinTaskTest extends JS assertFalse(a.isCompletedAbnormally()); assertFalse(a.isCancelled()); assertNull(a.getException()); + assertNull(a.getRawResult()); assertNull(pool.invoke(a)); @@ -58,11 +61,104 @@ public class ForkJoinTaskTest extends JS assertFalse(a.isCompletedAbnormally()); assertFalse(a.isCancelled()); assertNull(a.getException()); + assertNull(a.getRawResult()); } finally { joinPool(pool); } } + void checkNotDone(ForkJoinTask a) { + assertFalse(a.isDone()); + assertFalse(a.isCompletedNormally()); + assertFalse(a.isCompletedAbnormally()); + assertFalse(a.isCancelled()); + assertNull(a.getException()); + assertNull(a.getRawResult()); + + try { + a.get(0L, SECONDS); + shouldThrow(); + } catch (TimeoutException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } + } + + void checkCompletedNormally(ForkJoinTask a) { + checkCompletedNormally(a, null); + } + + void checkCompletedNormally(ForkJoinTask a, T expected) { + assertTrue(a.isDone()); + assertFalse(a.isCancelled()); + assertTrue(a.isCompletedNormally()); + assertFalse(a.isCompletedAbnormally()); + assertNull(a.getException()); + assertSame(expected, a.getRawResult()); + assertSame(expected, a.join()); + try { + assertSame(expected, a.get()); + } catch (Throwable fail) { threadUnexpectedException(fail); } + try { + assertSame(expected, a.get(5L, SECONDS)); + } catch (Throwable fail) { threadUnexpectedException(fail); } + } + + void checkCancelled(ForkJoinTask a) { + assertTrue(a.isDone()); + assertTrue(a.isCancelled()); + assertFalse(a.isCompletedNormally()); + assertTrue(a.isCompletedAbnormally()); + assertTrue(a.getException() instanceof CancellationException); + assertNull(a.getRawResult()); + + try { + a.join(); + shouldThrow(); + } catch (CancellationException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } + + try { + a.get(); + shouldThrow(); + } catch (CancellationException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } + + try { + a.get(5L, SECONDS); + shouldThrow(); + } catch (CancellationException success) { + } catch (Throwable fail) { threadUnexpectedException(fail); } + } + + void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { + assertTrue(a.isDone()); + assertFalse(a.isCancelled()); + assertFalse(a.isCompletedNormally()); + assertTrue(a.isCompletedAbnormally()); + assertSame(t, a.getException()); + assertNull(a.getRawResult()); + + try { + a.join(); + shouldThrow(); + } catch (Throwable expected) { + assertSame(t, expected); + } + + try { + a.get(); + shouldThrow(); + } catch (ExecutionException success) { + assertSame(t, success.getCause()); + } catch (Throwable fail) { threadUnexpectedException(fail); } + + try { + a.get(5L, SECONDS); + shouldThrow(); + } catch (ExecutionException success) { + assertSame(t, success.getCause()); + } catch (Throwable fail) { threadUnexpectedException(fail); } + } + /* * Testing coverage notes: * @@ -255,10 +351,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); assertNull(f.invoke()); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertFalse(f.isCancelled()); - assertFalse(f.isCompletedAbnormally()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -274,10 +367,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); f.quietlyInvoke(); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertFalse(f.isCancelled()); - assertFalse(f.isCompletedAbnormally()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -292,8 +382,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.join()); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -308,7 +397,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.get()); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -323,7 +412,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -354,7 +443,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); f.quietlyJoin(); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -371,8 +460,8 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); f.helpQuiesce(); assertEquals(21, f.number); - assertTrue(f.isDone()); assertEquals(0, getQueuedTaskCount()); + checkCompletedNormally(f); }}; testInvokeOnPool(mainPool(), a); } @@ -388,7 +477,9 @@ public class ForkJoinTaskTest extends JS try { f.invoke(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -401,7 +492,8 @@ public class ForkJoinTaskTest extends JS public void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); f.quietlyInvoke(); - assertTrue(f.isDone()); + assertTrue(f.getException() instanceof FJException); + checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(mainPool(), a); } @@ -417,7 +509,9 @@ public class ForkJoinTaskTest extends JS try { f.join(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -436,9 +530,7 @@ public class ForkJoinTaskTest extends JS } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertSame(cause, f.getException()); + checkCompletedAbnormally(f, cause); } }}; testInvokeOnPool(mainPool(), a); @@ -458,9 +550,7 @@ public class ForkJoinTaskTest extends JS } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertSame(cause, f.getException()); + checkCompletedAbnormally(f, cause); } }}; testInvokeOnPool(mainPool(), a); @@ -475,9 +565,8 @@ public class ForkJoinTaskTest extends JS FailingAsyncFib f = new FailingAsyncFib(8); assertSame(f, f.fork()); f.quietlyJoin(); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); assertTrue(f.getException() instanceof FJException); + checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(mainPool(), a); } @@ -494,10 +583,7 @@ public class ForkJoinTaskTest extends JS f.invoke(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); @@ -516,10 +602,7 @@ public class ForkJoinTaskTest extends JS f.join(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); @@ -538,10 +621,7 @@ public class ForkJoinTaskTest extends JS f.get(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); @@ -560,10 +640,7 @@ public class ForkJoinTaskTest extends JS f.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); @@ -579,10 +656,7 @@ public class ForkJoinTaskTest extends JS assertTrue(f.cancel(true)); assertSame(f, f.fork()); f.quietlyJoin(); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.isCancelled()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); }}; testInvokeOnPool(mainPool(), a); } @@ -627,7 +701,7 @@ public class ForkJoinTaskTest extends JS public void testInForkJoinPool2() { RecursiveAction a = new CheckedRecursiveAction() { public void realCompute() { - assertTrue(!inForkJoinPool()); + assertFalse(inForkJoinPool()); }}; assertNull(a.invoke()); } @@ -654,7 +728,9 @@ public class ForkJoinTaskTest extends JS try { f.invoke(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -668,10 +744,10 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); invokeAll(f, g); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); + checkCompletedNormally(f); + checkCompletedNormally(g); }}; testInvokeOnPool(mainPool(), a); } @@ -684,7 +760,7 @@ public class ForkJoinTaskTest extends JS public void realCompute() { AsyncFib f = new AsyncFib(8); invokeAll(f); - assertTrue(f.isDone()); + checkCompletedNormally(f); assertEquals(21, f.number); }}; testInvokeOnPool(mainPool(), a); @@ -700,12 +776,12 @@ public class ForkJoinTaskTest extends JS AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); invokeAll(f, g, h); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); - assertTrue(h.isDone()); assertEquals(13, h.number); + checkCompletedNormally(f); + checkCompletedNormally(g); + checkCompletedNormally(h); }}; testInvokeOnPool(mainPool(), a); } @@ -724,12 +800,12 @@ public class ForkJoinTaskTest extends JS set.add(g); set.add(h); invokeAll(set); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); - assertTrue(h.isDone()); assertEquals(13, h.number); + checkCompletedNormally(f); + checkCompletedNormally(g); + checkCompletedNormally(h); }}; testInvokeOnPool(mainPool(), a); } @@ -763,7 +839,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(f, g); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -778,7 +856,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(g); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -795,7 +875,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(f, g, h); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -816,7 +898,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(set); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(mainPool(), a); } @@ -834,8 +918,8 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertTrue(f.tryUnfork()); helpQuiesce(); - assertFalse(f.isDone()); - assertTrue(g.isDone()); + checkNotDone(f); + checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); } @@ -855,6 +939,10 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertTrue(getSurplusQueuedTaskCount() > 0); helpQuiesce(); + assertEquals(0, getSurplusQueuedTaskCount()); + checkCompletedNormally(f); + checkCompletedNormally(g); + checkCompletedNormally(h); }}; testInvokeOnPool(singletonPool(), a); } @@ -871,15 +959,16 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertSame(f, peekNextLocalTask()); assertNull(f.join()); - assertTrue(f.isDone()); + checkCompletedNormally(f); helpQuiesce(); + checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); } /** - * pollNextLocalTask returns most recent unexecuted task - * without executing it + * pollNextLocalTask returns most recent unexecuted task without + * executing it */ public void testPollNextLocalTask() { RecursiveAction a = new CheckedRecursiveAction() { @@ -890,14 +979,15 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertSame(f, pollNextLocalTask()); helpQuiesce(); - assertFalse(f.isDone()); + checkNotDone(f); + assertEquals(34, g.number); + checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); } /** - * pollTask returns an unexecuted task - * without executing it + * pollTask returns an unexecuted task without executing it */ public void testPollTask() { RecursiveAction a = new CheckedRecursiveAction() { @@ -908,8 +998,8 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertSame(f, pollTask()); helpQuiesce(); - assertFalse(f.isDone()); - assertTrue(g.isDone()); + checkNotDone(f); + checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); } @@ -927,14 +1017,16 @@ public class ForkJoinTaskTest extends JS assertSame(g, peekNextLocalTask()); assertNull(f.join()); helpQuiesce(); - assertTrue(f.isDone()); + checkCompletedNormally(f); + assertEquals(34, g.number); + checkCompletedNormally(g); }}; testInvokeOnPool(asyncSingletonPool(), a); } /** - * pollNextLocalTask returns least recent unexecuted task - * without executing it, in async mode + * pollNextLocalTask returns least recent unexecuted task without + * executing it, in async mode */ public void testPollNextLocalTaskAsync() { RecursiveAction a = new CheckedRecursiveAction() { @@ -945,15 +1037,16 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertSame(g, pollNextLocalTask()); helpQuiesce(); - assertTrue(f.isDone()); - assertFalse(g.isDone()); + assertEquals(21, f.number); + checkCompletedNormally(f); + checkNotDone(g); }}; testInvokeOnPool(asyncSingletonPool(), a); } /** - * pollTask returns an unexecuted task - * without executing it, in async mode + * pollTask returns an unexecuted task without executing it, in + * async mode */ public void testPollTaskAsync() { RecursiveAction a = new CheckedRecursiveAction() { @@ -964,8 +1057,9 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertSame(g, pollTask()); helpQuiesce(); - assertTrue(f.isDone()); - assertFalse(g.isDone()); + assertEquals(21, f.number); + checkCompletedNormally(f); + checkNotDone(g); }}; testInvokeOnPool(asyncSingletonPool(), a); } @@ -983,10 +1077,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); assertNull(f.invoke()); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertFalse(f.isCancelled()); - assertFalse(f.isCompletedAbnormally()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1002,10 +1093,7 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); f.quietlyInvoke(); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertFalse(f.isCancelled()); - assertFalse(f.isCompletedAbnormally()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1020,8 +1108,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.join()); assertEquals(21, f.number); - assertTrue(f.isDone()); - assertNull(f.getRawResult()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1036,7 +1123,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.get()); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1051,7 +1138,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1082,7 +1169,7 @@ public class ForkJoinTaskTest extends JS assertSame(f, f.fork()); f.quietlyJoin(); assertEquals(21, f.number); - assertTrue(f.isDone()); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1098,9 +1185,9 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); assertSame(f, f.fork()); f.helpQuiesce(); - assertEquals(21, f.number); - assertTrue(f.isDone()); assertEquals(0, getQueuedTaskCount()); + assertEquals(21, f.number); + checkCompletedNormally(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1116,7 +1203,9 @@ public class ForkJoinTaskTest extends JS try { f.invoke(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1129,7 +1218,8 @@ public class ForkJoinTaskTest extends JS public void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); f.quietlyInvoke(); - assertTrue(f.isDone()); + assertTrue(f.getException() instanceof FJException); + checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(singletonPool(), a); } @@ -1145,7 +1235,9 @@ public class ForkJoinTaskTest extends JS try { f.join(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1164,9 +1256,7 @@ public class ForkJoinTaskTest extends JS } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertSame(cause, f.getException()); + checkCompletedAbnormally(f, cause); } }}; testInvokeOnPool(singletonPool(), a); @@ -1186,9 +1276,7 @@ public class ForkJoinTaskTest extends JS } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertSame(cause, f.getException()); + checkCompletedAbnormally(f, cause); } }}; testInvokeOnPool(singletonPool(), a); @@ -1203,9 +1291,8 @@ public class ForkJoinTaskTest extends JS FailingAsyncFib f = new FailingAsyncFib(8); assertSame(f, f.fork()); f.quietlyJoin(); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); assertTrue(f.getException() instanceof FJException); + checkCompletedAbnormally(f, f.getException()); }}; testInvokeOnPool(singletonPool(), a); } @@ -1222,10 +1309,7 @@ public class ForkJoinTaskTest extends JS f.invoke(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(singletonPool(), a); @@ -1244,10 +1328,7 @@ public class ForkJoinTaskTest extends JS f.join(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(singletonPool(), a); @@ -1266,10 +1347,7 @@ public class ForkJoinTaskTest extends JS f.get(); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(singletonPool(), a); @@ -1288,10 +1366,7 @@ public class ForkJoinTaskTest extends JS f.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (CancellationException success) { - assertTrue(f.isDone()); - assertTrue(f.isCancelled()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); } }}; testInvokeOnPool(singletonPool(), a); @@ -1307,10 +1382,7 @@ public class ForkJoinTaskTest extends JS assertTrue(f.cancel(true)); assertSame(f, f.fork()); f.quietlyJoin(); - assertTrue(f.isDone()); - assertTrue(f.isCompletedAbnormally()); - assertTrue(f.isCancelled()); - assertTrue(f.getException() instanceof CancellationException); + checkCancelled(f); }}; testInvokeOnPool(singletonPool(), a); } @@ -1326,7 +1398,9 @@ public class ForkJoinTaskTest extends JS try { f.invoke(); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1340,10 +1414,10 @@ public class ForkJoinTaskTest extends JS AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); invokeAll(f, g); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); + checkCompletedNormally(f); + checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); } @@ -1356,7 +1430,7 @@ public class ForkJoinTaskTest extends JS public void realCompute() { AsyncFib f = new AsyncFib(8); invokeAll(f); - assertTrue(f.isDone()); + checkCompletedNormally(f); assertEquals(21, f.number); }}; testInvokeOnPool(singletonPool(), a); @@ -1372,12 +1446,12 @@ public class ForkJoinTaskTest extends JS AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); invokeAll(f, g, h); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); - assertTrue(h.isDone()); assertEquals(13, h.number); + checkCompletedNormally(f); + checkCompletedNormally(g); + checkCompletedNormally(h); }}; testInvokeOnPool(singletonPool(), a); } @@ -1396,12 +1470,12 @@ public class ForkJoinTaskTest extends JS set.add(g); set.add(h); invokeAll(set); - assertTrue(f.isDone()); assertEquals(21, f.number); - assertTrue(g.isDone()); assertEquals(34, g.number); - assertTrue(h.isDone()); assertEquals(13, h.number); + checkCompletedNormally(f); + checkCompletedNormally(g); + checkCompletedNormally(h); }}; testInvokeOnPool(singletonPool(), a); } @@ -1435,7 +1509,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(f, g); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1450,7 +1526,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(g); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1467,7 +1545,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(f, g, h); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(g, success); + } }}; testInvokeOnPool(singletonPool(), a); } @@ -1488,7 +1568,9 @@ public class ForkJoinTaskTest extends JS try { invokeAll(set); shouldThrow(); - } catch (FJException success) {} + } catch (FJException success) { + checkCompletedAbnormally(f, success); + } }}; testInvokeOnPool(singletonPool(), a); }