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.54 by jsr166, Sat Oct 21 06:52:36 2017 UTC vs.
Revision 1.58 by jsr166, Thu Jun 4 14:17:31 2020 UTC

# Line 87 | Line 87 | public class ForkJoinTaskTest extends JS
87          checkCompletedNormally(a, null);
88      }
89  
90 <    <T> void checkCompletedNormally(ForkJoinTask<T> a, T expected) {
90 >    <T> void checkCompletedNormally(ForkJoinTask<T> a, T expectedValue) {
91          assertTrue(a.isDone());
92          assertFalse(a.isCancelled());
93          assertTrue(a.isCompletedNormally());
94          assertFalse(a.isCompletedAbnormally());
95          assertNull(a.getException());
96 <        assertSame(expected, a.getRawResult());
96 >        assertSame(expectedValue, a.getRawResult());
97  
98          {
99              Thread.currentThread().interrupt();
100              long startTime = System.nanoTime();
101 <            assertSame(expected, a.join());
101 >            assertSame(expectedValue, a.join());
102              assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
103              Thread.interrupted();
104          }
# Line 113 | Line 113 | public class ForkJoinTaskTest extends JS
113  
114          assertFalse(a.cancel(false));
115          assertFalse(a.cancel(true));
116 +
117 +        T v1 = null, v2 = null;
118          try {
119 <            assertSame(expected, a.get());
120 <            assertSame(expected, a.get(randomTimeout(), randomTimeUnit()));
121 <        } catch (Exception fail) { threadUnexpectedException(fail); }
119 >            v1 = a.get();
120 >            v2 = a.get(randomTimeout(), randomTimeUnit());
121 >        } catch (Throwable fail) { threadUnexpectedException(fail); }
122 >        assertSame(expectedValue, v1);
123 >        assertSame(expectedValue, v2);
124      }
125  
126      void checkCancelled(ForkJoinTask a) {
# Line 495 | Line 499 | public class ForkJoinTaskTest extends JS
499                  AsyncFib f = new AsyncFib(8);
500                  assertSame(f, f.fork());
501                  helpQuiesce();
502 +                while (!f.isDone()) // wait out race
503 +                    ;
504                  assertEquals(21, f.number);
505                  assertEquals(0, getQueuedTaskCount());
506                  checkCompletedNormally(f);
# Line 1685 | Line 1691 | public class ForkJoinTaskTest extends JS
1691              assertEquals(
1692                  identityString(task) + "[Wrapped task = " + c.toString() + "]",
1693                  task.toString());
1694 +        }
1695 +    }
1696 +
1697 +    /**
1698 +     * adaptInterruptible(callable).toString() contains toString of wrapped task
1699 +     */
1700 +    public void testAdaptInterruptible_Callable_toString() {
1701 +        if (testImplementationDetails) {
1702 +            Callable<String> c = () -> "";
1703 +            ForkJoinTask<String> task = ForkJoinTask.adaptInterruptible(c);
1704 +            assertEquals(
1705 +                identityString(task) + "[Wrapped task = " + c.toString() + "]",
1706 +                task.toString());
1707          }
1708      }
1709   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines