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

Comparing jsr166/src/test/tck/ForkJoinPool8Test.java (file contents):
Revision 1.4 by dl, Thu Mar 21 19:06:54 2013 UTC vs.
Revision 1.8 by jsr166, Mon Jun 3 16:46:12 2013 UTC

# Line 59 | Line 59 | public class ForkJoinPool8Test extends J
59       * RecursiveAction and CountedCompleter, but with all actions
60       * executed in the common pool, generally implicitly via
61       * checkInvoke.
62 <     */
62 >     */
63  
64      private void checkInvoke(ForkJoinTask a) {
65          checkNotDone(a);
# Line 403 | Line 403 | public class ForkJoinPool8Test extends J
403      }
404  
405      /**
406     * helpQuiesce returns when tasks are complete.
407     * getQueuedTaskCount returns 0 when quiescent
408     */
409    public void testForkHelpQuiesce() {
410        RecursiveAction a = new CheckedRecursiveAction() {
411            public void realCompute() {
412                FibAction f = new FibAction(8);
413                assertSame(f, f.fork());
414                helpQuiesce();
415                assertEquals(21, f.result);
416                assertEquals(0, getQueuedTaskCount());
417                checkCompletedNormally(f);
418            }};
419        checkInvoke(a);
420    }
421
422    /**
406       * invoke task throws exception when task completes abnormally
407       */
408      public void testAbnormalInvoke() {
# Line 889 | Line 872 | public class ForkJoinPool8Test extends J
872          }
873      }
874  
875 <    static abstract class CCF extends CountedCompleter {
875 >    abstract static class CCF extends CountedCompleter {
876          int number;
877          int rnumber;
878  
# Line 910 | Line 893 | public class ForkJoinPool8Test extends J
893              f.onCompletion(f);
894              if ((p = f.getCompleter()) != null)
895                  p.tryComplete();
896 <            else
897 <                f.quietlyComplete();
896 >            else
897 >                f.quietlyComplete();
898          }
899      }
900  
# Line 943 | Line 926 | public class ForkJoinPool8Test extends J
926      }
927  
928      // Version of CCF with forced failure in left completions
929 <    static abstract class FailingCCF extends CountedCompleter {
929 >    abstract static class FailingCCF extends CountedCompleter {
930          int number;
931          int rnumber;
932  
# Line 964 | Line 947 | public class ForkJoinPool8Test extends J
947              f.onCompletion(f);
948              if ((p = f.getCompleter()) != null)
949                  p.tryComplete();
950 <            else
951 <                f.quietlyComplete();
950 >            else
951 >                f.quietlyComplete();
952          }
953      }
954  
# Line 990 | Line 973 | public class ForkJoinPool8Test extends J
973              completeExceptionally(new FJException());
974          }
975      }
976 <    
976 >
977      /**
978       * invoke returns when task completes normally.
979       * isCompletedAbnormally and isCancelled return false for normally
980       * completed tasks; getRawResult returns null.
981       */
982      public void testInvokeCC() {
983 <       ForkJoinTask a =  new CheckedFJTask() {
983 >        ForkJoinTask a = new CheckedFJTask() {
984              public void realCompute() {
985                  CCF f = new LCCF(null, 8);
986                  assertNull(f.invoke());
# Line 1013 | Line 996 | public class ForkJoinPool8Test extends J
996       * completed tasks
997       */
998      public void testQuietlyInvokeCC() {
999 <       ForkJoinTask a =  new CheckedFJTask() {
999 >        ForkJoinTask a = new CheckedFJTask() {
1000              public void realCompute() {
1001                  CCF f = new LCCF(null, 8);
1002                  f.quietlyInvoke();
# Line 1027 | Line 1010 | public class ForkJoinPool8Test extends J
1010       * join of a forked task returns when task completes
1011       */
1012      public void testForkJoinCC() {
1013 <       ForkJoinTask a =  new CheckedFJTask() {
1013 >        ForkJoinTask a = new CheckedFJTask() {
1014              public void realCompute() {
1015                  CCF f = new LCCF(null, 8);
1016                  assertSame(f, f.fork());
# Line 1042 | Line 1025 | public class ForkJoinPool8Test extends J
1025       * get of a forked task returns when task completes
1026       */
1027      public void testForkGetCC() {
1028 <       ForkJoinTask a =  new CheckedFJTask() {
1028 >        ForkJoinTask a = new CheckedFJTask() {
1029              public void realCompute() throws Exception {
1030                  CCF f = new LCCF(null, 8);
1031                  assertSame(f, f.fork());
# Line 1057 | Line 1040 | public class ForkJoinPool8Test extends J
1040       * timed get of a forked task returns when task completes
1041       */
1042      public void testForkTimedGetCC() {
1043 <       ForkJoinTask a =  new CheckedFJTask() {
1043 >        ForkJoinTask a = new CheckedFJTask() {
1044              public void realCompute() throws Exception {
1045                  CCF f = new LCCF(null, 8);
1046                  assertSame(f, f.fork());
# Line 1072 | Line 1055 | public class ForkJoinPool8Test extends J
1055       * timed get with null time unit throws NPE
1056       */
1057      public void testForkTimedGetNPECC() {
1058 <       ForkJoinTask a =  new CheckedFJTask() {
1058 >        ForkJoinTask a = new CheckedFJTask() {
1059              public void realCompute() throws Exception {
1060                  CCF f = new LCCF(null, 8);
1061                  assertSame(f, f.fork());
# Line 1088 | Line 1071 | public class ForkJoinPool8Test extends J
1071       * quietlyJoin of a forked task returns when task completes
1072       */
1073      public void testForkQuietlyJoinCC() {
1074 <       ForkJoinTask a =  new CheckedFJTask() {
1074 >        ForkJoinTask a = new CheckedFJTask() {
1075              public void realCompute() {
1076                  CCF f = new LCCF(null, 8);
1077                  assertSame(f, f.fork());
# Line 1100 | Line 1083 | public class ForkJoinPool8Test extends J
1083      }
1084  
1085      /**
1103     * helpQuiesce returns when tasks are complete.
1104     * getQueuedTaskCount returns 0 when quiescent
1105     */
1106    public void testForkHelpQuiesceCC() {
1107       ForkJoinTask a =  new CheckedFJTask() {
1108            public void realCompute() {
1109                CCF f = new LCCF(null, 8);
1110                assertSame(f, f.fork());
1111                helpQuiesce();
1112                assertEquals(21, f.number);
1113                assertEquals(0, getQueuedTaskCount());
1114                checkCompletedNormally(f);
1115            }};
1116        checkInvoke(a);
1117    }
1118
1119    /**
1086       * invoke task throws exception when task completes abnormally
1087       */
1088      public void testAbnormalInvokeCC() {
1089 <       ForkJoinTask a =  new CheckedFJTask() {
1089 >        ForkJoinTask a = new CheckedFJTask() {
1090              public void realCompute() {
1091                  FailingCCF f = new LFCCF(null, 8);
1092                  try {
# Line 1137 | Line 1103 | public class ForkJoinPool8Test extends J
1103       * quietlyInvoke task returns when task completes abnormally
1104       */
1105      public void testAbnormalQuietlyInvokeCC() {
1106 <       ForkJoinTask a =  new CheckedFJTask() {
1106 >        ForkJoinTask a = new CheckedFJTask() {
1107              public void realCompute() {
1108                  FailingCCF f = new LFCCF(null, 8);
1109                  f.quietlyInvoke();
# Line 1151 | Line 1117 | public class ForkJoinPool8Test extends J
1117       * join of a forked task throws exception when task completes abnormally
1118       */
1119      public void testAbnormalForkJoinCC() {
1120 <       ForkJoinTask a =  new CheckedFJTask() {
1120 >        ForkJoinTask a = new CheckedFJTask() {
1121              public void realCompute() {
1122                  FailingCCF f = new LFCCF(null, 8);
1123                  assertSame(f, f.fork());
# Line 1169 | Line 1135 | public class ForkJoinPool8Test extends J
1135       * get of a forked task throws exception when task completes abnormally
1136       */
1137      public void testAbnormalForkGetCC() {
1138 <       ForkJoinTask a =  new CheckedFJTask() {
1138 >        ForkJoinTask a = new CheckedFJTask() {
1139              public void realCompute() throws Exception {
1140                  FailingCCF f = new LFCCF(null, 8);
1141                  assertSame(f, f.fork());
# Line 1189 | Line 1155 | public class ForkJoinPool8Test extends J
1155       * timed get of a forked task throws exception when task completes abnormally
1156       */
1157      public void testAbnormalForkTimedGetCC() {
1158 <       ForkJoinTask a =  new CheckedFJTask() {
1158 >        ForkJoinTask a = new CheckedFJTask() {
1159              public void realCompute() throws Exception {
1160                  FailingCCF f = new LFCCF(null, 8);
1161                  assertSame(f, f.fork());
# Line 1209 | Line 1175 | public class ForkJoinPool8Test extends J
1175       * quietlyJoin of a forked task returns when task completes abnormally
1176       */
1177      public void testAbnormalForkQuietlyJoinCC() {
1178 <       ForkJoinTask a =  new CheckedFJTask() {
1178 >        ForkJoinTask a = new CheckedFJTask() {
1179              public void realCompute() {
1180                  FailingCCF f = new LFCCF(null, 8);
1181                  assertSame(f, f.fork());
# Line 1224 | Line 1190 | public class ForkJoinPool8Test extends J
1190       * invoke task throws exception when task cancelled
1191       */
1192      public void testCancelledInvokeCC() {
1193 <       ForkJoinTask a =  new CheckedFJTask() {
1193 >        ForkJoinTask a = new CheckedFJTask() {
1194              public void realCompute() {
1195                  CCF f = new LCCF(null, 8);
1196                  assertTrue(f.cancel(true));
# Line 1242 | Line 1208 | public class ForkJoinPool8Test extends J
1208       * join of a forked task throws exception when task cancelled
1209       */
1210      public void testCancelledForkJoinCC() {
1211 <       ForkJoinTask a =  new CheckedFJTask() {
1211 >        ForkJoinTask a = new CheckedFJTask() {
1212              public void realCompute() {
1213                  CCF f = new LCCF(null, 8);
1214                  assertTrue(f.cancel(true));
# Line 1261 | Line 1227 | public class ForkJoinPool8Test extends J
1227       * get of a forked task throws exception when task cancelled
1228       */
1229      public void testCancelledForkGetCC() {
1230 <       ForkJoinTask a =  new CheckedFJTask() {
1230 >        ForkJoinTask a = new CheckedFJTask() {
1231              public void realCompute() throws Exception {
1232                  CCF f = new LCCF(null, 8);
1233                  assertTrue(f.cancel(true));
# Line 1280 | Line 1246 | public class ForkJoinPool8Test extends J
1246       * timed get of a forked task throws exception when task cancelled
1247       */
1248      public void testCancelledForkTimedGetCC() throws Exception {
1249 <       ForkJoinTask a =  new CheckedFJTask() {
1249 >        ForkJoinTask a = new CheckedFJTask() {
1250              public void realCompute() throws Exception {
1251                  CCF f = new LCCF(null, 8);
1252                  assertTrue(f.cancel(true));
# Line 1299 | Line 1265 | public class ForkJoinPool8Test extends J
1265       * quietlyJoin of a forked task returns when task cancelled
1266       */
1267      public void testCancelledForkQuietlyJoinCC() {
1268 <       ForkJoinTask a =  new CheckedFJTask() {
1268 >        ForkJoinTask a = new CheckedFJTask() {
1269              public void realCompute() {
1270                  CCF f = new LCCF(null, 8);
1271                  assertTrue(f.cancel(true));
# Line 1314 | Line 1280 | public class ForkJoinPool8Test extends J
1280       * getPool of non-FJ task returns null
1281       */
1282      public void testGetPool2CC() {
1283 <       ForkJoinTask a =  new CheckedFJTask() {
1283 >        ForkJoinTask a = new CheckedFJTask() {
1284              public void realCompute() {
1285                  assertNull(getPool());
1286              }};
# Line 1325 | Line 1291 | public class ForkJoinPool8Test extends J
1291       * inForkJoinPool of non-FJ task returns false
1292       */
1293      public void testInForkJoinPool2CC() {
1294 <       ForkJoinTask a =  new CheckedFJTask() {
1294 >        ForkJoinTask a = new CheckedFJTask() {
1295              public void realCompute() {
1296                  assertFalse(inForkJoinPool());
1297              }};
# Line 1336 | Line 1302 | public class ForkJoinPool8Test extends J
1302       * setRawResult(null) succeeds
1303       */
1304      public void testSetRawResultCC() {
1305 <       ForkJoinTask a =  new CheckedFJTask() {
1305 >        ForkJoinTask a = new CheckedFJTask() {
1306              public void realCompute() {
1307                  setRawResult(null);
1308                  assertNull(getRawResult());
# Line 1348 | Line 1314 | public class ForkJoinPool8Test extends J
1314       * invoke task throws exception after invoking completeExceptionally
1315       */
1316      public void testCompleteExceptionally2CC() {
1317 <       ForkJoinTask a =  new CheckedFJTask() {
1317 >        ForkJoinTask a = new CheckedFJTask() {
1318              public void realCompute() {
1319                  CCF f = new LCCF(null, 8);
1320                  f.completeExceptionally(new FJException());
# Line 1366 | Line 1332 | public class ForkJoinPool8Test extends J
1332       * invokeAll(t1, t2) invokes all task arguments
1333       */
1334      public void testInvokeAll2CC() {
1335 <       ForkJoinTask a =  new CheckedFJTask() {
1335 >        ForkJoinTask a = new CheckedFJTask() {
1336              public void realCompute() {
1337                  CCF f = new LCCF(null, 8);
1338                  CCF g = new LCCF(null, 9);
# Line 1383 | Line 1349 | public class ForkJoinPool8Test extends J
1349       * invokeAll(tasks) with 1 argument invokes task
1350       */
1351      public void testInvokeAll1CC() {
1352 <       ForkJoinTask a =  new CheckedFJTask() {
1352 >        ForkJoinTask a = new CheckedFJTask() {
1353              public void realCompute() {
1354                  CCF f = new LCCF(null, 8);
1355                  invokeAll(f);
# Line 1397 | Line 1363 | public class ForkJoinPool8Test extends J
1363       * invokeAll(tasks) with > 2 argument invokes tasks
1364       */
1365      public void testInvokeAll3CC() {
1366 <       ForkJoinTask a =  new CheckedFJTask() {
1366 >        ForkJoinTask a = new CheckedFJTask() {
1367              public void realCompute() {
1368                  CCF f = new LCCF(null, 8);
1369                  CCF g = new LCCF(null, 9);
# Line 1417 | Line 1383 | public class ForkJoinPool8Test extends J
1383       * invokeAll(collection) invokes all tasks in the collection
1384       */
1385      public void testInvokeAllCollectionCC() {
1386 <       ForkJoinTask a =  new CheckedFJTask() {
1386 >        ForkJoinTask a = new CheckedFJTask() {
1387              public void realCompute() {
1388                  CCF f = new LCCF(null, 8);
1389                  CCF g = new LCCF(null, 9);
# Line 1441 | Line 1407 | public class ForkJoinPool8Test extends J
1407       * invokeAll(tasks) with any null task throws NPE
1408       */
1409      public void testInvokeAllNPECC() {
1410 <       ForkJoinTask a =  new CheckedFJTask() {
1410 >        ForkJoinTask a = new CheckedFJTask() {
1411              public void realCompute() {
1412                  CCF f = new LCCF(null, 8);
1413                  CCF g = new LCCF(null, 9);
# Line 1458 | Line 1424 | public class ForkJoinPool8Test extends J
1424       * invokeAll(t1, t2) throw exception if any task does
1425       */
1426      public void testAbnormalInvokeAll2CC() {
1427 <       ForkJoinTask a =  new CheckedFJTask() {
1427 >        ForkJoinTask a = new CheckedFJTask() {
1428              public void realCompute() {
1429                  CCF f = new LCCF(null, 8);
1430                  FailingCCF g = new LFCCF(null, 9);
# Line 1476 | Line 1442 | public class ForkJoinPool8Test extends J
1442       * invokeAll(tasks) with 1 argument throws exception if task does
1443       */
1444      public void testAbnormalInvokeAll1CC() {
1445 <       ForkJoinTask a =  new CheckedFJTask() {
1445 >        ForkJoinTask a = new CheckedFJTask() {
1446              public void realCompute() {
1447                  FailingCCF g = new LFCCF(null, 9);
1448                  try {
# Line 1493 | Line 1459 | public class ForkJoinPool8Test extends J
1459       * invokeAll(tasks) with > 2 argument throws exception if any task does
1460       */
1461      public void testAbnormalInvokeAll3CC() {
1462 <       ForkJoinTask a =  new CheckedFJTask() {
1462 >        ForkJoinTask a = new CheckedFJTask() {
1463              public void realCompute() {
1464                  CCF f = new LCCF(null, 8);
1465                  FailingCCF g = new LFCCF(null, 9);
# Line 1512 | Line 1478 | public class ForkJoinPool8Test extends J
1478       * invokeAll(collection)  throws exception if any task does
1479       */
1480      public void testAbnormalInvokeAllCollectionCC() {
1481 <       ForkJoinTask a =  new CheckedFJTask() {
1481 >        ForkJoinTask a = new CheckedFJTask() {
1482              public void realCompute() {
1483                  FailingCCF f = new LFCCF(null, 8);
1484                  CCF g = new LCCF(null, 9);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines