ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/RecursiveTaskTest.java
(Generate patch)

Comparing jsr166/src/test/tck/RecursiveTaskTest.java (file contents):
Revision 1.19 by jsr166, Thu Sep 16 00:52:49 2010 UTC vs.
Revision 1.20 by jsr166, Sun Nov 21 08:25:10 2010 UTC

# Line 8 | Line 8 | import junit.framework.*;
8   import java.util.concurrent.CancellationException;
9   import java.util.concurrent.ExecutionException;
10   import java.util.concurrent.ForkJoinPool;
11 + import java.util.concurrent.ForkJoinWorkerThread;
12   import java.util.concurrent.RecursiveTask;
13   import java.util.concurrent.TimeUnit;
14 + import java.util.concurrent.TimeoutException;
15 + import static java.util.concurrent.TimeUnit.SECONDS;
16   import java.util.HashSet;
17  
18   public class RecursiveTaskTest extends JSR166TestCase {
# Line 37 | Line 40 | public class RecursiveTaskTest extends J
40  
41      private <T> T testInvokeOnPool(ForkJoinPool pool, RecursiveTask<T> a) {
42          try {
43 <            assertFalse(a.isDone());
41 <            assertFalse(a.isCompletedNormally());
42 <            assertFalse(a.isCompletedAbnormally());
43 <            assertFalse(a.isCancelled());
43 >            checkNotDone(a);
44  
45              T result = pool.invoke(a);
46  
47 <            assertTrue(a.isDone());
48 <            assertTrue(a.isCompletedNormally());
49 <            assertFalse(a.isCompletedAbnormally());
50 <            assertFalse(a.isCancelled());
51 <            assertNull(a.getException());
47 >            checkCompletedNormally(a, result);
48              return result;
49          } finally {
50              joinPool(pool);
51          }
52      }
53  
54 +    void checkNotDone(RecursiveTask a) {
55 +        assertFalse(a.isDone());
56 +        assertFalse(a.isCompletedNormally());
57 +        assertFalse(a.isCompletedAbnormally());
58 +        assertFalse(a.isCancelled());
59 +        assertNull(a.getException());
60 +        assertNull(a.getRawResult());
61 +
62 +        if (! (Thread.currentThread() instanceof ForkJoinWorkerThread)) {
63 +            Thread.currentThread().interrupt();
64 +            try {
65 +                a.get();
66 +                shouldThrow();
67 +            } catch (InterruptedException success) {
68 +            } catch (Throwable fail) { threadUnexpectedException(fail); }
69 +
70 +            Thread.currentThread().interrupt();
71 +            try {
72 +                a.get(5L, SECONDS);
73 +                shouldThrow();
74 +            } catch (InterruptedException success) {
75 +            } catch (Throwable fail) { threadUnexpectedException(fail); }
76 +        }
77 +
78 +        try {
79 +            a.get(0L, SECONDS);
80 +            shouldThrow();
81 +        } catch (TimeoutException success) {
82 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
83 +    }
84 +
85 +    <T> void checkCompletedNormally(RecursiveTask<T> a, T expected) {
86 +        assertTrue(a.isDone());
87 +        assertFalse(a.isCancelled());
88 +        assertTrue(a.isCompletedNormally());
89 +        assertFalse(a.isCompletedAbnormally());
90 +        assertNull(a.getException());
91 +        assertSame(expected, a.getRawResult());
92 +        assertSame(expected, a.join());
93 +        try {
94 +            assertSame(expected, a.get());
95 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
96 +        try {
97 +            assertSame(expected, a.get(5L, SECONDS));
98 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
99 +    }
100 +
101 +    /**
102 +     * Waits for the task to complete, and checks that when it does,
103 +     * it will have an Integer result equals to the given int.
104 +     */
105 +    void checkCompletesNormally(RecursiveTask<Integer> a, int expected) {
106 +        Integer r = a.join();
107 +        assertEquals(expected, (int) r);
108 +        checkCompletedNormally(a, r);
109 +    }
110 +
111 +    /**
112 +     * Like checkCompletesNormally, but verifies that the task has
113 +     * already completed.
114 +     */
115 +    void checkCompletedNormally(RecursiveTask<Integer> a, int expected) {
116 +        Integer r = a.getRawResult();
117 +        assertEquals(expected, (int) r);
118 +        checkCompletedNormally(a, r);
119 +    }
120 +
121 +    void checkCancelled(RecursiveTask a) {
122 +        assertTrue(a.isDone());
123 +        assertTrue(a.isCancelled());
124 +        assertFalse(a.isCompletedNormally());
125 +        assertTrue(a.isCompletedAbnormally());
126 +        assertTrue(a.getException() instanceof CancellationException);
127 +        assertNull(a.getRawResult());
128 +
129 +        try {
130 +            a.join();
131 +            shouldThrow();
132 +        } catch (CancellationException success) {
133 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
134 +
135 +        try {
136 +            a.get();
137 +            shouldThrow();
138 +        } catch (CancellationException success) {
139 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
140 +
141 +        try {
142 +            a.get(5L, SECONDS);
143 +            shouldThrow();
144 +        } catch (CancellationException success) {
145 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
146 +    }
147 +
148 +    void checkTaskThrew(RecursiveTask a, Throwable t) {
149 +        assertTrue(a.isDone());
150 +        assertFalse(a.isCancelled());
151 +        assertFalse(a.isCompletedNormally());
152 +        assertTrue(a.isCompletedAbnormally());
153 +        assertSame(t, a.getException());
154 +        assertNull(a.getRawResult());
155 +
156 +        try {
157 +            a.join();
158 +            shouldThrow();
159 +        } catch (Throwable expected) {
160 +            assertSame(t, expected);
161 +        }
162 +
163 +        try {
164 +            a.get();
165 +            shouldThrow();
166 +        } catch (ExecutionException success) {
167 +            assertSame(t, success.getCause());
168 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
169 +
170 +        try {
171 +            a.get(5L, SECONDS);
172 +            shouldThrow();
173 +        } catch (ExecutionException success) {
174 +            assertSame(t, success.getCause());
175 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
176 +    }
177 +
178      static final class FJException extends RuntimeException {
179          FJException() { super(); }
180      }
# Line 74 | Line 194 | public class RecursiveTaskTest extends J
194              f1.fork();
195              return (new FibTask(n - 2)).compute() + f1.join();
196          }
197 +
198 +        public void publicSetRawResult(Integer result) {
199 +            setRawResult(result);
200 +        }
201      }
202  
203      // A recursive action failing in base case
# Line 103 | Line 227 | public class RecursiveTaskTest extends J
227                  FibTask f = new FibTask(8);
228                  Integer r = f.invoke();
229                  assertEquals(21, (int) r);
230 <                assertTrue(f.isDone());
107 <                assertFalse(f.isCancelled());
108 <                assertFalse(f.isCompletedAbnormally());
109 <                assertEquals(21, (int) f.getRawResult());
230 >                checkCompletedNormally(f, r);
231                  return r;
232              }};
233          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
# Line 122 | Line 243 | public class RecursiveTaskTest extends J
243              public Integer realCompute() {
244                  FibTask f = new FibTask(8);
245                  f.quietlyInvoke();
246 <                Integer r = f.getRawResult();
247 <                assertEquals(21, (int) r);
127 <                assertTrue(f.isDone());
128 <                assertFalse(f.isCancelled());
129 <                assertFalse(f.isCompletedAbnormally());
130 <                return r;
246 >                checkCompletedNormally(f, 21);
247 >                return NoResult;
248              }};
249 <        assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
249 >        assertSame(NoResult, testInvokeOnPool(mainPool(), a));
250      }
251  
252      /**
# Line 142 | Line 259 | public class RecursiveTaskTest extends J
259                  assertSame(f, f.fork());
260                  Integer r = f.join();
261                  assertEquals(21, (int) r);
262 <                assertTrue(f.isDone());
262 >                checkCompletedNormally(f, r);
263                  return r;
264              }};
265          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
# Line 158 | Line 275 | public class RecursiveTaskTest extends J
275                  assertSame(f, f.fork());
276                  Integer r = f.get();
277                  assertEquals(21, (int) r);
278 <                assertTrue(f.isDone());
278 >                checkCompletedNormally(f, r);
279                  return r;
280              }};
281          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
# Line 172 | Line 289 | public class RecursiveTaskTest extends J
289              public Integer realCompute() throws Exception {
290                  FibTask f = new FibTask(8);
291                  assertSame(f, f.fork());
292 <                Integer r = f.get(5L, TimeUnit.SECONDS);
292 >                Integer r = f.get(5L, SECONDS);
293                  assertEquals(21, (int) r);
294 <                assertTrue(f.isDone());
294 >                checkCompletedNormally(f, r);
295                  return r;
296              }};
297          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
# Line 191 | Line 308 | public class RecursiveTaskTest extends J
308                  f.quietlyJoin();
309                  Integer r = f.getRawResult();
310                  assertEquals(21, (int) r);
311 <                assertTrue(f.isDone());
311 >                checkCompletedNormally(f, r);
312                  return r;
313              }};
314          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
# Line 208 | Line 325 | public class RecursiveTaskTest extends J
325                  FibTask f = new FibTask(8);
326                  assertSame(f, f.fork());
327                  f.helpQuiesce();
211                Integer r = f.getRawResult();
212                assertEquals(21, (int) r);
213                assertTrue(f.isDone());
328                  assertEquals(0, getQueuedTaskCount());
329 <                return r;
329 >                checkCompletedNormally(f, 21);
330 >                return NoResult;
331              }};
332 <        assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
332 >        assertSame(NoResult, testInvokeOnPool(mainPool(), a));
333      }
334  
335  
# Line 228 | Line 343 | public class RecursiveTaskTest extends J
343                  try {
344                      f.invoke();
345                      shouldThrow();
346 <                    return NoResult;
347 <                } catch (FJException success) {}
346 >                } catch (FJException success) {
347 >                    checkTaskThrew(f, success);
348 >                }
349                  return NoResult;
350              }};
351          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 243 | Line 359 | public class RecursiveTaskTest extends J
359              public Integer realCompute() {
360                  FailingFibTask f = new FailingFibTask(8);
361                  f.quietlyInvoke();
362 <                assertTrue(f.isDone());
362 >                assertTrue(f.getException() instanceof FJException);
363 >                checkTaskThrew(f, f.getException());
364                  return NoResult;
365              }};
366          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 260 | Line 377 | public class RecursiveTaskTest extends J
377                  try {
378                      Integer r = f.join();
379                      shouldThrow();
380 <                    return r;
381 <                } catch (FJException success) {}
380 >                } catch (FJException success) {
381 >                    checkTaskThrew(f, success);
382 >                }
383                  return NoResult;
384              }};
385          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 278 | Line 396 | public class RecursiveTaskTest extends J
396                  try {
397                      Integer r = f.get();
398                      shouldThrow();
399 <                    return r;
400 <                } catch (ExecutionException success) {}
399 >                } catch (ExecutionException success) {
400 >                    checkTaskThrew(f, success.getCause());
401 >                }
402                  return NoResult;
403              }};
404          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 294 | Line 413 | public class RecursiveTaskTest extends J
413                  FailingFibTask f = new FailingFibTask(8);
414                  assertSame(f, f.fork());
415                  try {
416 <                    Integer r = f.get(5L, TimeUnit.SECONDS);
416 >                    Integer r = f.get(5L, SECONDS);
417                      shouldThrow();
418 <                    return r;
419 <                } catch (ExecutionException success) {}
418 >                } catch (ExecutionException success) {
419 >                    checkTaskThrew(f, success.getCause());
420 >                }
421                  return NoResult;
422              }};
423          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 312 | Line 432 | public class RecursiveTaskTest extends J
432                  FailingFibTask f = new FailingFibTask(8);
433                  assertSame(f, f.fork());
434                  f.quietlyJoin();
315                assertTrue(f.isDone());
316                assertTrue(f.isCompletedAbnormally());
435                  assertTrue(f.getException() instanceof FJException);
436 +                checkTaskThrew(f, f.getException());
437                  return NoResult;
438              }};
439          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 331 | Line 450 | public class RecursiveTaskTest extends J
450                  try {
451                      Integer r = f.invoke();
452                      shouldThrow();
453 <                    return r;
454 <                } catch (CancellationException success) {}
453 >                } catch (CancellationException success) {
454 >                    checkCancelled(f);
455 >                }
456                  return NoResult;
457              }};
458          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 350 | Line 470 | public class RecursiveTaskTest extends J
470                  try {
471                      Integer r = f.join();
472                      shouldThrow();
473 <                    return r;
474 <                } catch (CancellationException success) {}
473 >                } catch (CancellationException success) {
474 >                    checkCancelled(f);
475 >                }
476                  return NoResult;
477              }};
478          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 369 | Line 490 | public class RecursiveTaskTest extends J
490                  try {
491                      Integer r = f.get();
492                      shouldThrow();
493 <                    return r;
494 <                } catch (CancellationException success) {}
493 >                } catch (CancellationException success) {
494 >                    checkCancelled(f);
495 >                }
496                  return NoResult;
497              }};
498          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 386 | Line 508 | public class RecursiveTaskTest extends J
508                  assertTrue(f.cancel(true));
509                  assertSame(f, f.fork());
510                  try {
511 <                    Integer r = f.get(5L, TimeUnit.SECONDS);
511 >                    Integer r = f.get(5L, SECONDS);
512                      shouldThrow();
513 <                    return r;
514 <                } catch (CancellationException success) {}
513 >                } catch (CancellationException success) {
514 >                    checkCancelled(f);
515 >                }
516                  return NoResult;
517              }};
518          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 405 | Line 528 | public class RecursiveTaskTest extends J
528                  assertTrue(f.cancel(true));
529                  assertSame(f, f.fork());
530                  f.quietlyJoin();
531 <                assertTrue(f.isDone());
409 <                assertTrue(f.isCompletedAbnormally());
410 <                assertTrue(f.isCancelled());
411 <                assertTrue(f.getException() instanceof CancellationException);
531 >                checkCancelled(f);
532                  return NoResult;
533              }};
534          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 478 | Line 598 | public class RecursiveTaskTest extends J
598      }
599  
600      /**
601 <     * A reinitialized task may be re-invoked
601 >     * A reinitialized normally completed task may be re-invoked
602       */
603      public void testReinitialize() {
604          RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
605              public Integer realCompute() {
606                  FibTask f = new FibTask(8);
607 <                Integer r = f.invoke();
608 <                assertEquals(21, (int) r);
609 <                assertTrue(f.isDone());
610 <                assertFalse(f.isCancelled());
611 <                assertFalse(f.isCompletedAbnormally());
612 <                f.reinitialize();
613 <                r = f.invoke();
614 <                assertEquals(21, (int) r);
607 >                checkNotDone(f);
608 >
609 >                for (int i = 0; i < 3; i++) {
610 >                    Integer r = f.invoke();
611 >                    assertEquals(21, (int) r);
612 >                    checkCompletedNormally(f, r);
613 >                    f.reinitialize();
614 >                    f.publicSetRawResult(null);
615 >                    checkNotDone(f);
616 >                }
617 >                return NoResult;
618 >            }};
619 >        assertSame(NoResult, testInvokeOnPool(mainPool(), a));
620 >    }
621 >
622 >    /**
623 >     * A reinitialized abnormally completed task may be re-invoked
624 >     */
625 >    public void testReinitializeAbnormal() {
626 >        RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
627 >            public Integer realCompute() {
628 >                FailingFibTask f = new FailingFibTask(8);
629 >                checkNotDone(f);
630 >
631 >                for (int i = 0; i < 3; i++) {
632 >                    try {
633 >                        f.invoke();
634 >                        shouldThrow();
635 >                    } catch (FJException success) {
636 >                        checkTaskThrew(f, success);
637 >                    }
638 >                    f.reinitialize();
639 >                    checkNotDone(f);
640 >                }
641                  return NoResult;
642              }};
643          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 508 | Line 654 | public class RecursiveTaskTest extends J
654                  try {
655                      Integer r = f.invoke();
656                      shouldThrow();
657 <                    return r;
658 <                } catch (FJException success) {}
657 >                } catch (FJException success) {
658 >                    checkTaskThrew(f, success);
659 >                }
660                  return NoResult;
661              }};
662          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 524 | Line 671 | public class RecursiveTaskTest extends J
671                  FibTask f = new FibTask(8);
672                  f.complete(NoResult);
673                  Integer r = f.invoke();
527                assertTrue(f.isDone());
674                  assertSame(NoResult, r);
675 +                checkCompletedNormally(f, NoResult);
676                  return r;
677              }};
678          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 540 | Line 687 | public class RecursiveTaskTest extends J
687                  FibTask f = new FibTask(8);
688                  FibTask g = new FibTask(9);
689                  invokeAll(f, g);
690 <                assertTrue(f.isDone());
691 <                assertEquals(21, (int) f.join());
545 <                assertTrue(g.isDone());
546 <                assertEquals(34, (int) g.join());
690 >                checkCompletesNormally(f, 21);
691 >                checkCompletesNormally(g, 34);
692                  return NoResult;
693              }};
694          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 557 | Line 702 | public class RecursiveTaskTest extends J
702              public Integer realCompute() {
703                  FibTask f = new FibTask(8);
704                  invokeAll(f);
705 <                assertTrue(f.isDone());
561 <                assertEquals(21, (int) f.join());
705 >                checkCompletesNormally(f, 21);
706                  return NoResult;
707              }};
708          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 574 | Line 718 | public class RecursiveTaskTest extends J
718                  FibTask g = new FibTask(9);
719                  FibTask h = new FibTask(7);
720                  invokeAll(f, g, h);
721 <                assertTrue(f.isDone());
722 <                assertEquals(21, (int) f.join());
723 <                assertTrue(g.isDone());
580 <                assertEquals(34, (int) g.join());
581 <                assertTrue(h.isDone());
582 <                assertEquals(13, (int) h.join());
721 >                checkCompletesNormally(f, 21);
722 >                checkCompletesNormally(g, 34);
723 >                checkCompletesNormally(h, 13);
724                  return NoResult;
725              }};
726          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 599 | Line 740 | public class RecursiveTaskTest extends J
740                  set.add(g);
741                  set.add(h);
742                  invokeAll(set);
743 <                assertTrue(f.isDone());
744 <                assertEquals(21, (int) f.join());
745 <                assertTrue(g.isDone());
605 <                assertEquals(34, (int) g.join());
606 <                assertTrue(h.isDone());
607 <                assertEquals(13, (int) h.join());
743 >                checkCompletesNormally(f, 21);
744 >                checkCompletesNormally(g, 34);
745 >                checkCompletesNormally(h, 13);
746                  return NoResult;
747              }};
748          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 612 | Line 750 | public class RecursiveTaskTest extends J
750  
751  
752      /**
753 +     * invokeAll(tasks) with any null task throws NPE
754 +     */
755 +    public void testInvokeAllNPE() {
756 +        RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
757 +            public Integer realCompute() {
758 +                FibTask f = new FibTask(8);
759 +                FibTask g = new FibTask(9);
760 +                FibTask h = null;
761 +                try {
762 +                    invokeAll(f, g, h);
763 +                    shouldThrow();
764 +                } catch (NullPointerException success) {}
765 +                return NoResult;
766 +            }};
767 +        assertSame(NoResult, testInvokeOnPool(mainPool(), a));
768 +    }
769 +
770 +    /**
771       * invokeAll(t1, t2) throw exception if any task does
772       */
773      public void testAbnormalInvokeAll2() {
# Line 622 | Line 778 | public class RecursiveTaskTest extends J
778                  try {
779                      invokeAll(f, g);
780                      shouldThrow();
781 <                    return NoResult;
782 <                } catch (FJException success) {}
781 >                } catch (FJException success) {
782 >                    checkTaskThrew(g, success);
783 >                }
784                  return NoResult;
785              }};
786          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 639 | Line 796 | public class RecursiveTaskTest extends J
796                  try {
797                      invokeAll(g);
798                      shouldThrow();
799 <                    return NoResult;
800 <                } catch (FJException success) {}
799 >                } catch (FJException success) {
800 >                    checkTaskThrew(g, success);
801 >                }
802                  return NoResult;
803              }};
804          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 658 | Line 816 | public class RecursiveTaskTest extends J
816                  try {
817                      invokeAll(f, g, h);
818                      shouldThrow();
819 <                    return NoResult;
820 <                } catch (FJException success) {}
819 >                } catch (FJException success) {
820 >                    checkTaskThrew(g, success);
821 >                }
822                  return NoResult;
823              }};
824          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 681 | Line 840 | public class RecursiveTaskTest extends J
840                  try {
841                      invokeAll(set);
842                      shouldThrow();
843 <                    return NoResult;
844 <                } catch (FJException success) {}
843 >                } catch (FJException success) {
844 >                    checkTaskThrew(f, success);
845 >                }
846                  return NoResult;
847              }};
848          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 701 | Line 861 | public class RecursiveTaskTest extends J
861                  assertSame(f, f.fork());
862                  assertTrue(f.tryUnfork());
863                  helpQuiesce();
864 <                assertFalse(f.isDone());
865 <                assertTrue(g.isDone());
864 >                checkNotDone(f);
865 >                checkCompletedNormally(g, 34);
866                  return NoResult;
867              }};
868          assertSame(NoResult, testInvokeOnPool(singletonPool(), a));
# Line 723 | Line 883 | public class RecursiveTaskTest extends J
883                  assertSame(f, f.fork());
884                  assertTrue(getSurplusQueuedTaskCount() > 0);
885                  helpQuiesce();
886 +                checkCompletedNormally(f, 21);
887 +                checkCompletedNormally(g, 34);
888 +                checkCompletedNormally(h, 13);
889                  return NoResult;
890              }};
891          assertSame(NoResult, testInvokeOnPool(singletonPool(), a));
# Line 739 | Line 902 | public class RecursiveTaskTest extends J
902                  FibTask f = new FibTask(8);
903                  assertSame(f, f.fork());
904                  assertSame(f, peekNextLocalTask());
905 <                assertEquals(21, (int) f.join());
743 <                assertTrue(f.isDone());
905 >                checkCompletesNormally(f, 21);
906                  helpQuiesce();
907 +                checkCompletedNormally(g, 34);
908                  return NoResult;
909              }};
910          assertSame(NoResult, testInvokeOnPool(singletonPool(), a));
# Line 760 | Line 923 | public class RecursiveTaskTest extends J
923                  assertSame(f, f.fork());
924                  assertSame(f, pollNextLocalTask());
925                  helpQuiesce();
926 <                assertFalse(f.isDone());
926 >                checkNotDone(f);
927 >                checkCompletedNormally(g, 34);
928                  return NoResult;
929              }};
930          assertSame(NoResult, testInvokeOnPool(singletonPool(), a));
# Line 778 | Line 942 | public class RecursiveTaskTest extends J
942                  assertSame(f, f.fork());
943                  assertSame(f, pollTask());
944                  helpQuiesce();
945 <                assertFalse(f.isDone());
946 <                assertTrue(g.isDone());
945 >                checkNotDone(f);
946 >                checkCompletedNormally(g, 34);
947                  return NoResult;
948              }};
949          assertSame(NoResult, testInvokeOnPool(singletonPool(), a));
# Line 798 | Line 962 | public class RecursiveTaskTest extends J
962                  assertSame(g, peekNextLocalTask());
963                  assertEquals(21, (int) f.join());
964                  helpQuiesce();
965 <                assertTrue(f.isDone());
965 >                checkCompletedNormally(f, 21);
966 >                checkCompletedNormally(g, 34);
967                  return NoResult;
968              }};
969          assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a));
970      }
971  
972      /**
973 <     * pollNextLocalTask returns least recent unexecuted task
974 <     * without executing it, in async mode
973 >     * pollNextLocalTask returns least recent unexecuted task without
974 >     * executing it, in async mode
975       */
976      public void testPollNextLocalTaskAsync() {
977          RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
# Line 817 | Line 982 | public class RecursiveTaskTest extends J
982                  assertSame(f, f.fork());
983                  assertSame(g, pollNextLocalTask());
984                  helpQuiesce();
985 <                assertTrue(f.isDone());
986 <                assertFalse(g.isDone());
985 >                checkCompletedNormally(f, 21);
986 >                checkNotDone(g);
987                  return NoResult;
988              }};
989          assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a));
990      }
991  
992      /**
993 <     * pollTask returns an unexecuted task
994 <     * without executing it, in async mode
993 >     * pollTask returns an unexecuted task without executing it, in
994 >     * async mode
995       */
996      public void testPollTaskAsync() {
997          RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
# Line 837 | Line 1002 | public class RecursiveTaskTest extends J
1002                  assertSame(f, f.fork());
1003                  assertSame(g, pollTask());
1004                  helpQuiesce();
1005 <                assertTrue(f.isDone());
1006 <                assertFalse(g.isDone());
1005 >                checkCompletedNormally(f, 21);
1006 >                checkNotDone(g);
1007                  return NoResult;
1008              }};
1009          assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines