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

Comparing jsr166/src/test/tck/ForkJoinTaskTest.java (file contents):
Revision 1.11 by jsr166, Sat Sep 11 07:31:52 2010 UTC vs.
Revision 1.12 by jsr166, Mon Sep 13 07:22:29 2010 UTC

# Line 30 | Line 30 | public class ForkJoinTaskTest extends JS
30      public static void main(String[] args) {
31          junit.textui.TestRunner.run(suite());
32      }
33 +
34      public static Test suite() {
35          return new TestSuite(ForkJoinTaskTest.class);
36      }
# Line 227 | Line 228 | public class ForkJoinTaskTest extends JS
228       */
229      public void testInvoke() {
230          RecursiveAction a = new RecursiveAction() {
231 <                public void compute() {
232 <                    AsyncFib f = new AsyncFib(8);
233 <                    f.invoke();
234 <                    threadAssertTrue(f.number == 21);
235 <                    threadAssertTrue(f.isDone());
236 <                    threadAssertFalse(f.isCancelled());
237 <                    threadAssertFalse(f.isCompletedAbnormally());
238 <                    threadAssertTrue(f.getRawResult() == null);
239 <                }
239 <            };
231 >            public void compute() {
232 >                AsyncFib f = new AsyncFib(8);
233 >                f.invoke();
234 >                threadAssertTrue(f.number == 21);
235 >                threadAssertTrue(f.isDone());
236 >                threadAssertFalse(f.isCancelled());
237 >                threadAssertFalse(f.isCompletedAbnormally());
238 >                threadAssertTrue(f.getRawResult() == null);
239 >            }};
240          mainPool.invoke(a);
241      }
242  
# Line 247 | Line 247 | public class ForkJoinTaskTest extends JS
247       */
248      public void testQuietlyInvoke() {
249          RecursiveAction a = new RecursiveAction() {
250 <                public void compute() {
251 <                    AsyncFib f = new AsyncFib(8);
252 <                    f.quietlyInvoke();
253 <                    threadAssertTrue(f.number == 21);
254 <                    threadAssertTrue(f.isDone());
255 <                    threadAssertFalse(f.isCancelled());
256 <                    threadAssertFalse(f.isCompletedAbnormally());
257 <                    threadAssertTrue(f.getRawResult() == null);
258 <                }
259 <            };
250 >            public void compute() {
251 >                AsyncFib f = new AsyncFib(8);
252 >                f.quietlyInvoke();
253 >                threadAssertTrue(f.number == 21);
254 >                threadAssertTrue(f.isDone());
255 >                threadAssertFalse(f.isCancelled());
256 >                threadAssertFalse(f.isCompletedAbnormally());
257 >                threadAssertTrue(f.getRawResult() == null);
258 >            }};
259          mainPool.invoke(a);
260      }
261  
# Line 265 | Line 264 | public class ForkJoinTaskTest extends JS
264       */
265      public void testForkJoin() {
266          RecursiveAction a = new RecursiveAction() {
267 <                public void compute() {
268 <                    AsyncFib f = new AsyncFib(8);
269 <                    f.fork();
270 <                    f.join();
271 <                    threadAssertTrue(f.number == 21);
272 <                    threadAssertTrue(f.isDone());
273 <                    threadAssertTrue(f.getRawResult() == null);
274 <                }
276 <            };
267 >            public void compute() {
268 >                AsyncFib f = new AsyncFib(8);
269 >                f.fork();
270 >                f.join();
271 >                threadAssertTrue(f.number == 21);
272 >                threadAssertTrue(f.isDone());
273 >                threadAssertTrue(f.getRawResult() == null);
274 >            }};
275          mainPool.invoke(a);
276      }
277  
# Line 282 | Line 280 | public class ForkJoinTaskTest extends JS
280       */
281      public void testForkGet() {
282          RecursiveAction a = new RecursiveAction() {
283 <                public void compute() {
284 <                    try {
285 <                        AsyncFib f = new AsyncFib(8);
286 <                        f.fork();
287 <                        f.get();
288 <                        threadAssertTrue(f.number == 21);
289 <                        threadAssertTrue(f.isDone());
290 <                    } catch (Exception ex) {
291 <                        unexpectedException(ex);
294 <                    }
283 >            public void compute() {
284 >                try {
285 >                    AsyncFib f = new AsyncFib(8);
286 >                    f.fork();
287 >                    f.get();
288 >                    threadAssertTrue(f.number == 21);
289 >                    threadAssertTrue(f.isDone());
290 >                } catch (Exception ex) {
291 >                    unexpectedException(ex);
292                  }
293 <            };
293 >            }};
294          mainPool.invoke(a);
295      }
296  
# Line 302 | Line 299 | public class ForkJoinTaskTest extends JS
299       */
300      public void testForkTimedGet() {
301          RecursiveAction a = new RecursiveAction() {
302 <                public void compute() {
303 <                    try {
304 <                        AsyncFib f = new AsyncFib(8);
305 <                        f.fork();
306 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
307 <                        threadAssertTrue(f.number == 21);
308 <                        threadAssertTrue(f.isDone());
309 <                    } catch (Exception ex) {
310 <                        unexpectedException(ex);
314 <                    }
302 >            public void compute() {
303 >                try {
304 >                    AsyncFib f = new AsyncFib(8);
305 >                    f.fork();
306 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
307 >                    threadAssertTrue(f.number == 21);
308 >                    threadAssertTrue(f.isDone());
309 >                } catch (Exception ex) {
310 >                    unexpectedException(ex);
311                  }
312 <            };
312 >            }};
313          mainPool.invoke(a);
314      }
315  
# Line 322 | Line 318 | public class ForkJoinTaskTest extends JS
318       */
319      public void testForkTimedGetNPE() {
320          RecursiveAction a = new RecursiveAction() {
321 <                public void compute() {
322 <                    try {
323 <                        AsyncFib f = new AsyncFib(8);
324 <                        f.fork();
325 <                        f.get(5L, null);
326 <                        shouldThrow();
327 <                    } catch (NullPointerException success) {
328 <                    } catch (Exception ex) {
329 <                        unexpectedException(ex);
334 <                    }
321 >            public void compute() {
322 >                try {
323 >                    AsyncFib f = new AsyncFib(8);
324 >                    f.fork();
325 >                    f.get(5L, null);
326 >                    shouldThrow();
327 >                } catch (NullPointerException success) {
328 >                } catch (Exception ex) {
329 >                    unexpectedException(ex);
330                  }
331 <            };
331 >            }};
332          mainPool.invoke(a);
333      }
334  
# Line 342 | Line 337 | public class ForkJoinTaskTest extends JS
337       */
338      public void testForkQuietlyJoin() {
339          RecursiveAction a = new RecursiveAction() {
340 <                public void compute() {
341 <                    AsyncFib f = new AsyncFib(8);
342 <                    f.fork();
343 <                    f.quietlyJoin();
344 <                    threadAssertTrue(f.number == 21);
345 <                    threadAssertTrue(f.isDone());
346 <                }
352 <            };
340 >            public void compute() {
341 >                AsyncFib f = new AsyncFib(8);
342 >                f.fork();
343 >                f.quietlyJoin();
344 >                threadAssertTrue(f.number == 21);
345 >                threadAssertTrue(f.isDone());
346 >            }};
347          mainPool.invoke(a);
348      }
349  
# Line 360 | Line 354 | public class ForkJoinTaskTest extends JS
354       */
355      public void testForkHelpQuiesce() {
356          RecursiveAction a = new RecursiveAction() {
357 <                public void compute() {
358 <                    AsyncFib f = new AsyncFib(8);
359 <                    f.fork();
360 <                    f.helpQuiesce();
361 <                    threadAssertTrue(f.number == 21);
362 <                    threadAssertTrue(f.isDone());
363 <                    threadAssertTrue(getQueuedTaskCount() == 0);
364 <                }
371 <            };
357 >            public void compute() {
358 >                AsyncFib f = new AsyncFib(8);
359 >                f.fork();
360 >                f.helpQuiesce();
361 >                threadAssertTrue(f.number == 21);
362 >                threadAssertTrue(f.isDone());
363 >                threadAssertTrue(getQueuedTaskCount() == 0);
364 >            }};
365          mainPool.invoke(a);
366      }
367  
# Line 378 | Line 371 | public class ForkJoinTaskTest extends JS
371       */
372      public void testAbnormalInvoke() {
373          RecursiveAction a = new RecursiveAction() {
374 <                public void compute() {
375 <                    try {
376 <                        FailingAsyncFib f = new FailingAsyncFib(8);
377 <                        f.invoke();
378 <                        shouldThrow();
379 <                    } catch (FJException success) {
387 <                    }
374 >            public void compute() {
375 >                try {
376 >                    FailingAsyncFib f = new FailingAsyncFib(8);
377 >                    f.invoke();
378 >                    shouldThrow();
379 >                } catch (FJException success) {
380                  }
381 <            };
381 >            }};
382          mainPool.invoke(a);
383      }
384  
# Line 395 | Line 387 | public class ForkJoinTaskTest extends JS
387       */
388      public void testAbnormalQuietlyInvoke() {
389          RecursiveAction a = new RecursiveAction() {
390 <                public void compute() {
391 <                    FailingAsyncFib f = new FailingAsyncFib(8);
392 <                    f.quietlyInvoke();
393 <                    threadAssertTrue(f.isDone());
394 <                }
403 <            };
390 >            public void compute() {
391 >                FailingAsyncFib f = new FailingAsyncFib(8);
392 >                f.quietlyInvoke();
393 >                threadAssertTrue(f.isDone());
394 >            }};
395          mainPool.invoke(a);
396      }
397  
# Line 409 | Line 400 | public class ForkJoinTaskTest extends JS
400       */
401      public void testAbnormalForkJoin() {
402          RecursiveAction a = new RecursiveAction() {
403 <                public void compute() {
404 <                    try {
405 <                        FailingAsyncFib f = new FailingAsyncFib(8);
406 <                        f.fork();
407 <                        f.join();
408 <                        shouldThrow();
409 <                    } catch (FJException success) {
419 <                    }
403 >            public void compute() {
404 >                try {
405 >                    FailingAsyncFib f = new FailingAsyncFib(8);
406 >                    f.fork();
407 >                    f.join();
408 >                    shouldThrow();
409 >                } catch (FJException success) {
410                  }
411 <            };
411 >            }};
412          mainPool.invoke(a);
413      }
414  
# Line 427 | Line 417 | public class ForkJoinTaskTest extends JS
417       */
418      public void testAbnormalForkGet() {
419          RecursiveAction a = new RecursiveAction() {
420 <                public void compute() {
421 <                    try {
422 <                        FailingAsyncFib f = new FailingAsyncFib(8);
423 <                        f.fork();
424 <                        f.get();
425 <                        shouldThrow();
426 <                    } catch (ExecutionException success) {
427 <                    } catch (Exception ex) {
428 <                        unexpectedException(ex);
439 <                    }
420 >            public void compute() {
421 >                try {
422 >                    FailingAsyncFib f = new FailingAsyncFib(8);
423 >                    f.fork();
424 >                    f.get();
425 >                    shouldThrow();
426 >                } catch (ExecutionException success) {
427 >                } catch (Exception ex) {
428 >                    unexpectedException(ex);
429                  }
430 <            };
430 >            }};
431          mainPool.invoke(a);
432      }
433  
# Line 447 | Line 436 | public class ForkJoinTaskTest extends JS
436       */
437      public void testAbnormalForkTimedGet() {
438          RecursiveAction a = new RecursiveAction() {
439 <                public void compute() {
440 <                    try {
441 <                        FailingAsyncFib f = new FailingAsyncFib(8);
442 <                        f.fork();
443 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
444 <                        shouldThrow();
445 <                    } catch (ExecutionException success) {
446 <                    } catch (Exception ex) {
447 <                        unexpectedException(ex);
459 <                    }
439 >            public void compute() {
440 >                try {
441 >                    FailingAsyncFib f = new FailingAsyncFib(8);
442 >                    f.fork();
443 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
444 >                    shouldThrow();
445 >                } catch (ExecutionException success) {
446 >                } catch (Exception ex) {
447 >                    unexpectedException(ex);
448                  }
449 <            };
449 >            }};
450          mainPool.invoke(a);
451      }
452  
# Line 467 | Line 455 | public class ForkJoinTaskTest extends JS
455       */
456      public void testAbnormalForkQuietlyJoin() {
457          RecursiveAction a = new RecursiveAction() {
458 <                public void compute() {
459 <                    FailingAsyncFib f = new FailingAsyncFib(8);
460 <                    f.fork();
461 <                    f.quietlyJoin();
462 <                    threadAssertTrue(f.isDone());
463 <                    threadAssertTrue(f.isCompletedAbnormally());
464 <                    threadAssertTrue(f.getException() instanceof FJException);
465 <                }
478 <            };
458 >            public void compute() {
459 >                FailingAsyncFib f = new FailingAsyncFib(8);
460 >                f.fork();
461 >                f.quietlyJoin();
462 >                threadAssertTrue(f.isDone());
463 >                threadAssertTrue(f.isCompletedAbnormally());
464 >                threadAssertTrue(f.getException() instanceof FJException);
465 >            }};
466          mainPool.invoke(a);
467      }
468  
# Line 484 | Line 471 | public class ForkJoinTaskTest extends JS
471       */
472      public void testCancelledInvoke() {
473          RecursiveAction a = new RecursiveAction() {
474 <                public void compute() {
475 <                    try {
476 <                        AsyncFib f = new AsyncFib(8);
477 <                        f.cancel(true);
478 <                        f.invoke();
479 <                        shouldThrow();
480 <                    } catch (CancellationException success) {
494 <                    }
474 >            public void compute() {
475 >                try {
476 >                    AsyncFib f = new AsyncFib(8);
477 >                    f.cancel(true);
478 >                    f.invoke();
479 >                    shouldThrow();
480 >                } catch (CancellationException success) {
481                  }
482 <            };
482 >            }};
483          mainPool.invoke(a);
484      }
485  
# Line 502 | Line 488 | public class ForkJoinTaskTest extends JS
488       */
489      public void testCancelledForkJoin() {
490          RecursiveAction a = new RecursiveAction() {
491 <                public void compute() {
492 <                    try {
493 <                        AsyncFib f = new AsyncFib(8);
494 <                        f.cancel(true);
495 <                        f.fork();
496 <                        f.join();
497 <                        shouldThrow();
498 <                    } catch (CancellationException success) {
513 <                    }
491 >            public void compute() {
492 >                try {
493 >                    AsyncFib f = new AsyncFib(8);
494 >                    f.cancel(true);
495 >                    f.fork();
496 >                    f.join();
497 >                    shouldThrow();
498 >                } catch (CancellationException success) {
499                  }
500 <            };
500 >            }};
501          mainPool.invoke(a);
502      }
503  
# Line 521 | Line 506 | public class ForkJoinTaskTest extends JS
506       */
507      public void testCancelledForkGet() {
508          RecursiveAction a = new RecursiveAction() {
509 <                public void compute() {
510 <                    try {
511 <                        AsyncFib f = new AsyncFib(8);
512 <                        f.cancel(true);
513 <                        f.fork();
514 <                        f.get();
515 <                        shouldThrow();
516 <                    } catch (CancellationException success) {
517 <                    } catch (Exception ex) {
518 <                        unexpectedException(ex);
534 <                    }
509 >            public void compute() {
510 >                try {
511 >                    AsyncFib f = new AsyncFib(8);
512 >                    f.cancel(true);
513 >                    f.fork();
514 >                    f.get();
515 >                    shouldThrow();
516 >                } catch (CancellationException success) {
517 >                } catch (Exception ex) {
518 >                    unexpectedException(ex);
519                  }
520 <            };
520 >            }};
521          mainPool.invoke(a);
522      }
523  
# Line 542 | Line 526 | public class ForkJoinTaskTest extends JS
526       */
527      public void testCancelledForkTimedGet() {
528          RecursiveAction a = new RecursiveAction() {
529 <                public void compute() {
530 <                    try {
531 <                        AsyncFib f = new AsyncFib(8);
532 <                        f.cancel(true);
533 <                        f.fork();
534 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
535 <                        shouldThrow();
536 <                    } catch (CancellationException success) {
537 <                    } catch (Exception ex) {
538 <                        unexpectedException(ex);
555 <                    }
529 >            public void compute() {
530 >                try {
531 >                    AsyncFib f = new AsyncFib(8);
532 >                    f.cancel(true);
533 >                    f.fork();
534 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
535 >                    shouldThrow();
536 >                } catch (CancellationException success) {
537 >                } catch (Exception ex) {
538 >                    unexpectedException(ex);
539                  }
540 <            };
540 >            }};
541          mainPool.invoke(a);
542      }
543  
# Line 563 | Line 546 | public class ForkJoinTaskTest extends JS
546       */
547      public void testCancelledForkQuietlyJoin() {
548          RecursiveAction a = new RecursiveAction() {
549 <                public void compute() {
550 <                    AsyncFib f = new AsyncFib(8);
551 <                    f.cancel(true);
552 <                    f.fork();
553 <                    f.quietlyJoin();
554 <                    threadAssertTrue(f.isDone());
555 <                    threadAssertTrue(f.isCompletedAbnormally());
556 <                    threadAssertTrue(f.getException() instanceof CancellationException);
557 <                }
575 <            };
549 >            public void compute() {
550 >                AsyncFib f = new AsyncFib(8);
551 >                f.cancel(true);
552 >                f.fork();
553 >                f.quietlyJoin();
554 >                threadAssertTrue(f.isDone());
555 >                threadAssertTrue(f.isCompletedAbnormally());
556 >                threadAssertTrue(f.getException() instanceof CancellationException);
557 >            }};
558          mainPool.invoke(a);
559      }
560  
# Line 581 | Line 563 | public class ForkJoinTaskTest extends JS
563       */
564      public void testGetPool() {
565          RecursiveAction a = new RecursiveAction() {
566 <                public void compute() {
567 <                    threadAssertTrue(getPool() == mainPool);
568 <                }
587 <            };
566 >            public void compute() {
567 >                threadAssertTrue(getPool() == mainPool);
568 >            }};
569          mainPool.invoke(a);
570      }
571  
# Line 593 | Line 574 | public class ForkJoinTaskTest extends JS
574       */
575      public void testGetPool2() {
576          RecursiveAction a = new RecursiveAction() {
577 <                public void compute() {
578 <                    threadAssertTrue(getPool() == null);
579 <                }
599 <            };
577 >            public void compute() {
578 >                threadAssertTrue(getPool() == null);
579 >            }};
580          a.invoke();
581      }
582  
# Line 605 | Line 585 | public class ForkJoinTaskTest extends JS
585       */
586      public void testInForkJoinPool() {
587          RecursiveAction a = new RecursiveAction() {
588 <                public void compute() {
589 <                    threadAssertTrue(inForkJoinPool());
590 <                }
611 <            };
588 >            public void compute() {
589 >                threadAssertTrue(inForkJoinPool());
590 >            }};
591          mainPool.invoke(a);
592      }
593  
# Line 617 | Line 596 | public class ForkJoinTaskTest extends JS
596       */
597      public void testInForkJoinPool2() {
598          RecursiveAction a = new RecursiveAction() {
599 <                public void compute() {
600 <                    threadAssertTrue(!inForkJoinPool());
601 <                }
623 <            };
599 >            public void compute() {
600 >                threadAssertTrue(!inForkJoinPool());
601 >            }};
602          a.invoke();
603      }
604  
# Line 629 | Line 607 | public class ForkJoinTaskTest extends JS
607       */
608      public void testSetRawResult() {
609          RecursiveAction a = new RecursiveAction() {
610 <                public void compute() {
611 <                    setRawResult(null);
612 <                }
635 <            };
610 >            public void compute() {
611 >                setRawResult(null);
612 >            }};
613          a.invoke();
614      }
615  
# Line 641 | Line 618 | public class ForkJoinTaskTest extends JS
618       */
619      public void testCompleteExceptionally() {
620          RecursiveAction a = new RecursiveAction() {
621 <                public void compute() {
622 <                    try {
623 <                        AsyncFib f = new AsyncFib(8);
624 <                        f.completeExceptionally(new FJException());
625 <                        f.invoke();
626 <                        shouldThrow();
627 <                    } catch (FJException success) {
651 <                    }
621 >            public void compute() {
622 >                try {
623 >                    AsyncFib f = new AsyncFib(8);
624 >                    f.completeExceptionally(new FJException());
625 >                    f.invoke();
626 >                    shouldThrow();
627 >                } catch (FJException success) {
628                  }
629 <            };
629 >            }};
630          mainPool.invoke(a);
631      }
632  
# Line 659 | Line 635 | public class ForkJoinTaskTest extends JS
635       */
636      public void testInvokeAll2() {
637          RecursiveAction a = new RecursiveAction() {
638 <                public void compute() {
639 <                    AsyncFib f = new AsyncFib(8);
640 <                    AsyncFib g = new AsyncFib(9);
641 <                    invokeAll(f, g);
642 <                    threadAssertTrue(f.isDone());
643 <                    threadAssertTrue(f.number == 21);
644 <                    threadAssertTrue(g.isDone());
645 <                    threadAssertTrue(g.number == 34);
646 <                }
671 <            };
638 >            public void compute() {
639 >                AsyncFib f = new AsyncFib(8);
640 >                AsyncFib g = new AsyncFib(9);
641 >                invokeAll(f, g);
642 >                threadAssertTrue(f.isDone());
643 >                threadAssertTrue(f.number == 21);
644 >                threadAssertTrue(g.isDone());
645 >                threadAssertTrue(g.number == 34);
646 >            }};
647          mainPool.invoke(a);
648      }
649  
# Line 677 | Line 652 | public class ForkJoinTaskTest extends JS
652       */
653      public void testInvokeAll1() {
654          RecursiveAction a = new RecursiveAction() {
655 <                public void compute() {
656 <                    AsyncFib f = new AsyncFib(8);
657 <                    invokeAll(f);
658 <                    threadAssertTrue(f.isDone());
659 <                    threadAssertTrue(f.number == 21);
660 <                }
686 <            };
655 >            public void compute() {
656 >                AsyncFib f = new AsyncFib(8);
657 >                invokeAll(f);
658 >                threadAssertTrue(f.isDone());
659 >                threadAssertTrue(f.number == 21);
660 >            }};
661          mainPool.invoke(a);
662      }
663  
# Line 692 | Line 666 | public class ForkJoinTaskTest extends JS
666       */
667      public void testInvokeAll3() {
668          RecursiveAction a = new RecursiveAction() {
669 <                public void compute() {
670 <                    AsyncFib f = new AsyncFib(8);
671 <                    AsyncFib g = new AsyncFib(9);
672 <                    AsyncFib h = new AsyncFib(7);
673 <                    invokeAll(f, g, h);
674 <                    threadAssertTrue(f.isDone());
675 <                    threadAssertTrue(f.number == 21);
676 <                    threadAssertTrue(g.isDone());
677 <                    threadAssertTrue(g.number == 34);
678 <                    threadAssertTrue(h.isDone());
679 <                    threadAssertTrue(h.number == 13);
680 <                }
707 <            };
669 >            public void compute() {
670 >                AsyncFib f = new AsyncFib(8);
671 >                AsyncFib g = new AsyncFib(9);
672 >                AsyncFib h = new AsyncFib(7);
673 >                invokeAll(f, g, h);
674 >                threadAssertTrue(f.isDone());
675 >                threadAssertTrue(f.number == 21);
676 >                threadAssertTrue(g.isDone());
677 >                threadAssertTrue(g.number == 34);
678 >                threadAssertTrue(h.isDone());
679 >                threadAssertTrue(h.number == 13);
680 >            }};
681          mainPool.invoke(a);
682      }
683  
# Line 713 | Line 686 | public class ForkJoinTaskTest extends JS
686       */
687      public void testInvokeAllCollection() {
688          RecursiveAction a = new RecursiveAction() {
689 <                public void compute() {
690 <                    AsyncFib f = new AsyncFib(8);
691 <                    AsyncFib g = new AsyncFib(9);
692 <                    AsyncFib h = new AsyncFib(7);
693 <                    HashSet set = new HashSet();
694 <                    set.add(f);
695 <                    set.add(g);
696 <                    set.add(h);
697 <                    invokeAll(set);
698 <                    threadAssertTrue(f.isDone());
699 <                    threadAssertTrue(f.number == 21);
700 <                    threadAssertTrue(g.isDone());
701 <                    threadAssertTrue(g.number == 34);
702 <                    threadAssertTrue(h.isDone());
703 <                    threadAssertTrue(h.number == 13);
704 <                }
732 <            };
689 >            public void compute() {
690 >                AsyncFib f = new AsyncFib(8);
691 >                AsyncFib g = new AsyncFib(9);
692 >                AsyncFib h = new AsyncFib(7);
693 >                HashSet set = new HashSet();
694 >                set.add(f);
695 >                set.add(g);
696 >                set.add(h);
697 >                invokeAll(set);
698 >                threadAssertTrue(f.isDone());
699 >                threadAssertTrue(f.number == 21);
700 >                threadAssertTrue(g.isDone());
701 >                threadAssertTrue(g.number == 34);
702 >                threadAssertTrue(h.isDone());
703 >                threadAssertTrue(h.number == 13);
704 >            }};
705          mainPool.invoke(a);
706      }
707  
# Line 739 | Line 711 | public class ForkJoinTaskTest extends JS
711       */
712      public void testInvokeAllNPE() {
713          RecursiveAction a = new RecursiveAction() {
714 <                public void compute() {
715 <                    try {
716 <                        AsyncFib f = new AsyncFib(8);
717 <                        AsyncFib g = new AsyncFib(9);
718 <                        AsyncFib h = null;
719 <                        invokeAll(f, g, h);
720 <                        shouldThrow();
721 <                    } catch (NullPointerException success) {
750 <                    }
714 >            public void compute() {
715 >                try {
716 >                    AsyncFib f = new AsyncFib(8);
717 >                    AsyncFib g = new AsyncFib(9);
718 >                    AsyncFib h = null;
719 >                    invokeAll(f, g, h);
720 >                    shouldThrow();
721 >                } catch (NullPointerException success) {
722                  }
723 <            };
723 >            }};
724          mainPool.invoke(a);
725      }
726  
# Line 758 | Line 729 | public class ForkJoinTaskTest extends JS
729       */
730      public void testAbnormalInvokeAll2() {
731          RecursiveAction a = new RecursiveAction() {
732 <                public void compute() {
733 <                    try {
734 <                        AsyncFib f = new AsyncFib(8);
735 <                        FailingAsyncFib g = new FailingAsyncFib(9);
736 <                        invokeAll(f, g);
737 <                        shouldThrow();
738 <                    } catch (FJException success) {
768 <                    }
732 >            public void compute() {
733 >                try {
734 >                    AsyncFib f = new AsyncFib(8);
735 >                    FailingAsyncFib g = new FailingAsyncFib(9);
736 >                    invokeAll(f, g);
737 >                    shouldThrow();
738 >                } catch (FJException success) {
739                  }
740 <            };
740 >            }};
741          mainPool.invoke(a);
742      }
743  
# Line 776 | Line 746 | public class ForkJoinTaskTest extends JS
746       */
747      public void testAbnormalInvokeAll1() {
748          RecursiveAction a = new RecursiveAction() {
749 <                public void compute() {
750 <                    try {
751 <                        FailingAsyncFib g = new FailingAsyncFib(9);
752 <                        invokeAll(g);
753 <                        shouldThrow();
754 <                    } catch (FJException success) {
785 <                    }
749 >            public void compute() {
750 >                try {
751 >                    FailingAsyncFib g = new FailingAsyncFib(9);
752 >                    invokeAll(g);
753 >                    shouldThrow();
754 >                } catch (FJException success) {
755                  }
756 <            };
756 >            }};
757          mainPool.invoke(a);
758      }
759  
# Line 793 | Line 762 | public class ForkJoinTaskTest extends JS
762       */
763      public void testAbnormalInvokeAll3() {
764          RecursiveAction a = new RecursiveAction() {
765 <                public void compute() {
766 <                    try {
767 <                        AsyncFib f = new AsyncFib(8);
768 <                        FailingAsyncFib g = new FailingAsyncFib(9);
769 <                        AsyncFib h = new AsyncFib(7);
770 <                        invokeAll(f, g, h);
771 <                        shouldThrow();
772 <                    } catch (FJException success) {
804 <                    }
765 >            public void compute() {
766 >                try {
767 >                    AsyncFib f = new AsyncFib(8);
768 >                    FailingAsyncFib g = new FailingAsyncFib(9);
769 >                    AsyncFib h = new AsyncFib(7);
770 >                    invokeAll(f, g, h);
771 >                    shouldThrow();
772 >                } catch (FJException success) {
773                  }
774 <            };
774 >            }};
775          mainPool.invoke(a);
776      }
777  
# Line 812 | Line 780 | public class ForkJoinTaskTest extends JS
780       */
781      public void testAbnormalInvokeAllCollection() {
782          RecursiveAction a = new RecursiveAction() {
783 <                public void compute() {
784 <                    try {
785 <                        FailingAsyncFib f = new FailingAsyncFib(8);
786 <                        AsyncFib g = new AsyncFib(9);
787 <                        AsyncFib h = new AsyncFib(7);
788 <                        HashSet set = new HashSet();
789 <                        set.add(f);
790 <                        set.add(g);
791 <                        set.add(h);
792 <                        invokeAll(set);
793 <                        shouldThrow();
794 <                    } catch (FJException success) {
827 <                    }
783 >            public void compute() {
784 >                try {
785 >                    FailingAsyncFib f = new FailingAsyncFib(8);
786 >                    AsyncFib g = new AsyncFib(9);
787 >                    AsyncFib h = new AsyncFib(7);
788 >                    HashSet set = new HashSet();
789 >                    set.add(f);
790 >                    set.add(g);
791 >                    set.add(h);
792 >                    invokeAll(set);
793 >                    shouldThrow();
794 >                } catch (FJException success) {
795                  }
796 <            };
796 >            }};
797          mainPool.invoke(a);
798      }
799  
# Line 836 | Line 803 | public class ForkJoinTaskTest extends JS
803       */
804      public void testTryUnfork() {
805          RecursiveAction a = new RecursiveAction() {
806 <                public void compute() {
807 <                    AsyncFib g = new AsyncFib(9);
808 <                    g.fork();
809 <                    AsyncFib f = new AsyncFib(8);
810 <                    f.fork();
811 <                    threadAssertTrue(f.tryUnfork());
812 <                    helpQuiesce();
813 <                    threadAssertFalse(f.isDone());
814 <                    threadAssertTrue(g.isDone());
815 <                }
849 <            };
806 >            public void compute() {
807 >                AsyncFib g = new AsyncFib(9);
808 >                g.fork();
809 >                AsyncFib f = new AsyncFib(8);
810 >                f.fork();
811 >                threadAssertTrue(f.tryUnfork());
812 >                helpQuiesce();
813 >                threadAssertFalse(f.isDone());
814 >                threadAssertTrue(g.isDone());
815 >            }};
816          singletonPool.invoke(a);
817      }
818  
# Line 856 | Line 822 | public class ForkJoinTaskTest extends JS
822       */
823      public void testGetSurplusQueuedTaskCount() {
824          RecursiveAction a = new RecursiveAction() {
825 <                public void compute() {
826 <                    AsyncFib h = new AsyncFib(7);
827 <                    h.fork();
828 <                    AsyncFib g = new AsyncFib(9);
829 <                    g.fork();
830 <                    AsyncFib f = new AsyncFib(8);
831 <                    f.fork();
832 <                    threadAssertTrue(getSurplusQueuedTaskCount() > 0);
833 <                    helpQuiesce();
834 <                }
869 <            };
825 >            public void compute() {
826 >                AsyncFib h = new AsyncFib(7);
827 >                h.fork();
828 >                AsyncFib g = new AsyncFib(9);
829 >                g.fork();
830 >                AsyncFib f = new AsyncFib(8);
831 >                f.fork();
832 >                threadAssertTrue(getSurplusQueuedTaskCount() > 0);
833 >                helpQuiesce();
834 >            }};
835          singletonPool.invoke(a);
836      }
837  
# Line 875 | Line 840 | public class ForkJoinTaskTest extends JS
840       */
841      public void testPeekNextLocalTask() {
842          RecursiveAction a = new RecursiveAction() {
843 <                public void compute() {
844 <                    AsyncFib g = new AsyncFib(9);
845 <                    g.fork();
846 <                    AsyncFib f = new AsyncFib(8);
847 <                    f.fork();
848 <                    threadAssertTrue(peekNextLocalTask() == f);
849 <                    f.join();
850 <                    threadAssertTrue(f.isDone());
851 <                    helpQuiesce();
852 <                }
888 <            };
843 >            public void compute() {
844 >                AsyncFib g = new AsyncFib(9);
845 >                g.fork();
846 >                AsyncFib f = new AsyncFib(8);
847 >                f.fork();
848 >                threadAssertTrue(peekNextLocalTask() == f);
849 >                f.join();
850 >                threadAssertTrue(f.isDone());
851 >                helpQuiesce();
852 >            }};
853          singletonPool.invoke(a);
854      }
855  
# Line 895 | Line 859 | public class ForkJoinTaskTest extends JS
859       */
860      public void testPollNextLocalTask() {
861          RecursiveAction a = new RecursiveAction() {
862 <                public void compute() {
863 <                    AsyncFib g = new AsyncFib(9);
864 <                    g.fork();
865 <                    AsyncFib f = new AsyncFib(8);
866 <                    f.fork();
867 <                    threadAssertTrue(pollNextLocalTask() == f);
868 <                    helpQuiesce();
869 <                    threadAssertFalse(f.isDone());
870 <                }
907 <            };
862 >            public void compute() {
863 >                AsyncFib g = new AsyncFib(9);
864 >                g.fork();
865 >                AsyncFib f = new AsyncFib(8);
866 >                f.fork();
867 >                threadAssertTrue(pollNextLocalTask() == f);
868 >                helpQuiesce();
869 >                threadAssertFalse(f.isDone());
870 >            }};
871          singletonPool.invoke(a);
872      }
873  
# Line 914 | Line 877 | public class ForkJoinTaskTest extends JS
877       */
878      public void testPollTask() {
879          RecursiveAction a = new RecursiveAction() {
880 <                public void compute() {
881 <                    AsyncFib g = new AsyncFib(9);
882 <                    g.fork();
883 <                    AsyncFib f = new AsyncFib(8);
884 <                    f.fork();
885 <                    threadAssertTrue(pollTask() == f);
886 <                    helpQuiesce();
887 <                    threadAssertFalse(f.isDone());
888 <                    threadAssertTrue(g.isDone());
889 <                }
927 <            };
880 >            public void compute() {
881 >                AsyncFib g = new AsyncFib(9);
882 >                g.fork();
883 >                AsyncFib f = new AsyncFib(8);
884 >                f.fork();
885 >                threadAssertTrue(pollTask() == f);
886 >                helpQuiesce();
887 >                threadAssertFalse(f.isDone());
888 >                threadAssertTrue(g.isDone());
889 >            }};
890          singletonPool.invoke(a);
891      }
892  
# Line 933 | Line 895 | public class ForkJoinTaskTest extends JS
895       */
896      public void testPeekNextLocalTaskAsync() {
897          RecursiveAction a = new RecursiveAction() {
898 <                public void compute() {
899 <                    AsyncFib g = new AsyncFib(9);
900 <                    g.fork();
901 <                    AsyncFib f = new AsyncFib(8);
902 <                    f.fork();
903 <                    threadAssertTrue(peekNextLocalTask() == g);
904 <                    f.join();
905 <                    helpQuiesce();
906 <                    threadAssertTrue(f.isDone());
907 <                }
946 <            };
898 >            public void compute() {
899 >                AsyncFib g = new AsyncFib(9);
900 >                g.fork();
901 >                AsyncFib f = new AsyncFib(8);
902 >                f.fork();
903 >                threadAssertTrue(peekNextLocalTask() == g);
904 >                f.join();
905 >                helpQuiesce();
906 >                threadAssertTrue(f.isDone());
907 >            }};
908          asyncSingletonPool.invoke(a);
909      }
910  
# Line 953 | Line 914 | public class ForkJoinTaskTest extends JS
914       */
915      public void testPollNextLocalTaskAsync() {
916          RecursiveAction a = new RecursiveAction() {
917 <                public void compute() {
918 <                    AsyncFib g = new AsyncFib(9);
919 <                    g.fork();
920 <                    AsyncFib f = new AsyncFib(8);
921 <                    f.fork();
922 <                    threadAssertTrue(pollNextLocalTask() == g);
923 <                    helpQuiesce();
924 <                    threadAssertTrue(f.isDone());
925 <                    threadAssertFalse(g.isDone());
926 <                }
966 <            };
917 >            public void compute() {
918 >                AsyncFib g = new AsyncFib(9);
919 >                g.fork();
920 >                AsyncFib f = new AsyncFib(8);
921 >                f.fork();
922 >                threadAssertTrue(pollNextLocalTask() == g);
923 >                helpQuiesce();
924 >                threadAssertTrue(f.isDone());
925 >                threadAssertFalse(g.isDone());
926 >            }};
927          asyncSingletonPool.invoke(a);
928      }
929  
# Line 973 | Line 933 | public class ForkJoinTaskTest extends JS
933       */
934      public void testPollTaskAsync() {
935          RecursiveAction a = new RecursiveAction() {
936 <                public void compute() {
937 <                    AsyncFib g = new AsyncFib(9);
938 <                    g.fork();
939 <                    AsyncFib f = new AsyncFib(8);
940 <                    f.fork();
941 <                    threadAssertTrue(pollTask() == g);
942 <                    helpQuiesce();
943 <                    threadAssertTrue(f.isDone());
944 <                    threadAssertFalse(g.isDone());
945 <                }
986 <            };
936 >            public void compute() {
937 >                AsyncFib g = new AsyncFib(9);
938 >                g.fork();
939 >                AsyncFib f = new AsyncFib(8);
940 >                f.fork();
941 >                threadAssertTrue(pollTask() == g);
942 >                helpQuiesce();
943 >                threadAssertTrue(f.isDone());
944 >                threadAssertFalse(g.isDone());
945 >            }};
946          asyncSingletonPool.invoke(a);
947      }
948   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines