View Javadoc

    1   /*
    2    * Created on 18.08.2004
    3    */
    4   package net.sourceforge.pmd.dfa;
    5
    6   import static org.junit.Assert.assertTrue;
    7
    8   import java.util.List;
    9
    10  import net.sourceforge.pmd.PMD;
    11  import net.sourceforge.pmd.lang.dfa.DataFlowNode;
    12  import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
    13  import net.sourceforge.pmd.testframework.ParserTst;
    14
    15  import org.junit.Test;
    16
    17  public class AcceptanceTest extends ParserTst {
    18
    19      @Test
    20      public void testbook() throws Throwable {
    21          getOrderedNodes(ASTMethodDeclarator.class, FOO);
    22      }
    23
    24      private static final String FOO =
    25              "class Foo {" + PMD.EOL +
    26              " void bar() {" + PMD.EOL +
    27              "  int x = 2;" + PMD.EOL +
    28              " }" + PMD.EOL +
    29              "}";
    30
    31      @Test
    32      public void testLabelledBreakLockup() throws Throwable {
    33          getOrderedNodes(ASTMethodDeclarator.class, LABELLED_BREAK_LOCKUP);
    34      }
    35
    36      private static final String LABELLED_BREAK_LOCKUP =
    37              "class Foo {" + PMD.EOL +
    38              " void bar(int x) {" + PMD.EOL +
    39              "  here: if (x>2) {" + PMD.EOL +
    40              "   break here;" + PMD.EOL +
    41              "  }" + PMD.EOL +
    42              " }" + PMD.EOL +
    43              "}";
    44
    45      private boolean check(int[][] array, List methodNodes) {
    46          for (int i = 0; i < methodNodes.size(); i++) {
    47              ASTMethodDeclarator decl = (ASTMethodDeclarator) methodNodes.get(i);
    48              DataFlowNode inode = decl.getDataFlowNode();
    49              for (int j = 0; j < inode.getChildren().size(); j++) {
    50          	DataFlowNode child = inode.getChildren().get(j);
    51                  if (array[i][j] != child.getIndex() - 1) {
    52                      return false;
    53                  }
    54              }
    55          }
    56          return true;
    57      }
    58
    59      @Test
    60      public void test_1() throws Throwable {
    61          assertTrue(check(TEST1_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST1)));
    62      }
    63
    64      @Test
    65      public void test_2() throws Throwable {
    66          assertTrue(check(TEST2_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST2)));
    67      }
    68
    69      @Test
    70      public void test_3() throws Throwable {
    71          assertTrue(check(TEST3_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST3)));
    72      }
    73
    74      @Test
    75      public void test_4() throws Throwable {
    76          assertTrue(check(TEST4_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST4)));
    77      }
    78
    79      @Test
    80      public void test_6() throws Throwable {
    81          assertTrue(check(TEST5_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST6)));
    82      }
    83
    84      @Test
    85      public void test_7() throws Throwable {
    86          assertTrue(check(TEST5_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST7)));
    87      }
    88
    89      @Test
    90      public void test_8() throws Throwable {
    91          assertTrue(check(TEST8_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST8)));
    92      }
    93
    94      @Test
    95      public void test_9() throws Throwable {
    96          assertTrue(check(TEST5_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST9)));
    97      }
    98
    99      @Test
    100     public void test_10() throws Throwable {
    101         assertTrue(check(TEST8_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST10)));
    102     }
    103
    104     @Test
    105     public void test_11() throws Throwable {
    106         assertTrue(check(TEST8_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST11)));
    107     }
    108
    109     @Test
    110     public void test_12() throws Throwable {
    111         assertTrue(check(TEST12_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST12)));
    112     }
    113
    114     @Test
    115     public void test_13() throws Throwable {
    116         assertTrue(check(TEST13_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST13)));
    117     }
    118
    119     @Test
    120     public void test_14() throws Throwable {
    121         assertTrue(check(TEST14_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST14)));
    122     }
    123
    124     @Test
    125     public void test_15() throws Throwable {
    126         assertTrue(check(TEST15_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST15)));
    127     }
    128
    129     @Test
    130     public void test_16() throws Throwable {
    131         assertTrue(check(TEST16_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST16)));
    132     }
    133
    134     @Test
    135     public void test_17() throws Throwable {
    136         assertTrue(check(TEST17_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST17)));
    137     }
    138
    139     @Test
    140     public void test_18() throws Throwable {
    141         assertTrue(check(TEST18_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST18)));
    142     }
    143
    144     @Test
    145     public void test_19() throws Throwable {
    146         assertTrue(check(TEST19_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST19)));
    147     }
    148
    149     @Test
    150     public void test_20() throws Throwable {
    151         assertTrue(check(TEST20_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST20)));
    152     }
    153
    154     @Test
    155     public void test_21() throws Throwable {
    156         assertTrue(check(TEST21_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST21)));
    157     }
    158
    159     @Test
    160     public void test_22() throws Throwable {
    161         assertTrue(check(TEST22_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST22)));
    162     }
    163
    164     @Test
    165     public void test_23() throws Throwable {
    166         assertTrue(check(TEST23_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST23)));
    167     }
    168
    169     @Test
    170     public void test_24() throws Throwable {
    171         assertTrue(check(TEST24_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST24)));
    172     }
    173
    174     @Test
    175     public void test_25() throws Throwable {
    176         assertTrue(check(TEST25_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST25)));
    177     }
    178
    179     @Test
    180     public void test_26() throws Throwable {
    181         assertTrue(check(TEST26_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST26)));
    182     }
    183
    184     @Test
    185     public void test_27() throws Throwable {
    186         assertTrue(check(TEST27_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST27)));
    187     }
    188
    189     @Test
    190     public void test_28() throws Throwable {
    191         assertTrue(check(TEST28_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST28)));
    192     }
    193
    194     @Test
    195     public void test_29() throws Throwable {
    196         assertTrue(check(TEST29_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST29)));
    197     }
    198
    199     @Test
    200     public void test_30() throws Throwable {
    201         assertTrue(check(TEST30_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST30)));
    202     }
    203
    204     //  first dimension: the index of a node
    205     //  second dimension: the indices of the children
    206     private static final int[][] TEST1_NODES = {
    207         {1},
    208         {2},
    209         {3},
    210         {4, 6},
    211         {5},
    212         {6},
    213         {}
    214     };
    215
    216     private static final String TEST1 =
    217             "class Foo {" + PMD.EOL +
    218             " void test_1() {" + PMD.EOL +
    219             "  int x = 0;" + PMD.EOL +
    220             "  if (x == 0) {" + PMD.EOL +
    221             "   x++;" + PMD.EOL +
    222             "   x = 0;" + PMD.EOL +
    223             "  }" + PMD.EOL +
    224             " }" + PMD.EOL +
    225             " }";
    226
    227     private static final int[][] TEST2_NODES = {
    228         {1},
    229         {2},
    230         {3},
    231         {5, 7},
    232         {3},
    233         {6},
    234         {4},
    235         {}
    236     };
    237
    238     private static final String TEST2 =
    239             "class Foo {" + PMD.EOL +
    240             " public void test_2() {" + PMD.EOL +
    241             "  for (int i = 0; i < 1; i++) {" + PMD.EOL +
    242             "   i++;" + PMD.EOL +
    243             "   i = 8;" + PMD.EOL +
    244             "  }" + PMD.EOL +
    245             " }" + PMD.EOL +
    246             " }";
    247
    248     private static final int[][] TEST3_NODES = {
    249         {1},
    250         {2},
    251         {3},
    252         {4, 5},
    253         {3},
    254         {}
    255     };
    256
    257     private static final String TEST3 =
    258             "public class Foo {" + PMD.EOL +
    259             " public void test_3() {" + PMD.EOL +
    260             "  for (int i = 0; i < 1; i++) {" + PMD.EOL +
    261             "  }" + PMD.EOL +
    262             " }" + PMD.EOL +
    263             " }";
    264
    265
    266     private static final int[][] TEST4_NODES = {
    267         {1},
    268         {2},
    269         {3},
    270         {}
    271     };
    272
    273     private static final String TEST4 =
    274             "public class Foo {" + PMD.EOL +
    275             " public void test_4() {" + PMD.EOL +
    276             "  for (; ;) {" + PMD.EOL +
    277             "  }" + PMD.EOL +
    278             " }" + PMD.EOL +
    279             " }";
    280
    281     private static final int[][] TEST5_NODES = {
    282         {1},
    283         {2},
    284         {3},
    285         {4},
    286         {}
    287     };
    288
    289     private static final String TEST6 =
    290             "public class Foo {" + PMD.EOL +
    291             " public void test_6() {" + PMD.EOL +
    292             "  for (int i = 0; ;) {" + PMD.EOL +
    293             "  }" + PMD.EOL +
    294             " }" + PMD.EOL +
    295             " }";
    296
    297     private static final String TEST7 =
    298             "public class Foo {" + PMD.EOL +
    299             " public void test_7() {" + PMD.EOL +
    300             "  for (int i = 0; i < 0;) {" + PMD.EOL +
    301             "  }" + PMD.EOL +
    302             " }" + PMD.EOL +
    303             " }";
    304
    305     private static final int[][] TEST8_NODES = {
    306         {1},
    307         {2},
    308         {3},
    309         {4, 5},
    310         {3},
    311         {}
    312     };
    313
    314     public static final String TEST8 =
    315             "public class Foo {" + PMD.EOL +
    316             " public void test_8() {" + PMD.EOL +
    317             "  for (int i = 0; ; i++) {" + PMD.EOL +
    318             "  }" + PMD.EOL +
    319             " }" + PMD.EOL +
    320             " }";
    321
    322     public static final String TEST9 =
    323             "public class Foo {" + PMD.EOL +
    324             " public void test_9() {" + PMD.EOL +
    325             "  int i = 0;" + PMD.EOL +
    326             "  for (; i < 0;) {" + PMD.EOL +
    327             "  }" + PMD.EOL +
    328             " }" + PMD.EOL +
    329             " }";
    330
    331     public static final String TEST10 =
    332             "public class Foo {" + PMD.EOL +
    333             " public void test_10() {" + PMD.EOL +
    334             "  int i = 0;" + PMD.EOL +
    335             "  for (; i < 0; i++) {" + PMD.EOL +
    336             "  }" + PMD.EOL +
    337             " }" + PMD.EOL +
    338             " }";
    339
    340     public static final String TEST11 =
    341             "public class Foo {" + PMD.EOL +
    342             " public void test_11() {" + PMD.EOL +
    343             "  int i = 0;" + PMD.EOL +
    344             "  for (; ; i++) {" + PMD.EOL +
    345             "  }" + PMD.EOL +
    346             " }" + PMD.EOL +
    347             " }";
    348
    349     private static final int[][] TEST12_NODES = {
    350         {1},
    351         {2},
    352         {3},
    353         {4, 5},
    354         {3},
    355         {}
    356     };
    357     public static final String TEST12 =
    358             "public class Foo {" + PMD.EOL +
    359             " public void test_12() {" + PMD.EOL +
    360             "  for (; ;) {" + PMD.EOL +
    361             "   int i = 0;" + PMD.EOL +
    362             "  }" + PMD.EOL +
    363             " }" + PMD.EOL +
    364             " }";
    365
    366     private static final int[][] TEST13_NODES = {
    367         {1},
    368         {2},
    369         {3},
    370         {5, 9},
    371         {3},
    372         {6},
    373         {7, 8},
    374         {8},
    375         {4},
    376         {}
    377     };
    378     public static final String TEST13 =
    379             "public class Foo {" + PMD.EOL +
    380             " public void test_13() {" + PMD.EOL +
    381             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    382             "   i = 9;" + PMD.EOL +
    383             "   if (i < 8) {" + PMD.EOL +
    384             "    i = 7;" + PMD.EOL +
    385             "   }" + PMD.EOL +
    386             "   i = 6;" + PMD.EOL +
    387             "  }" + PMD.EOL +
    388             " }" + PMD.EOL +
    389             " }";
    390
    391     private static final int[][] TEST14_NODES = {
    392         {1},
    393         {2},
    394         {3},
    395         {5, 8},
    396         {3},
    397         {6},
    398         {7, 4},
    399         {4},
    400         {}
    401     };
    402     public static final String TEST14 =
    403             "public class Foo {" + PMD.EOL +
    404             " public void test_14() {" + PMD.EOL +
    405             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    406             "   i = 9;" + PMD.EOL +
    407             "   if (i < 8) {" + PMD.EOL +
    408             "    i = 7;" + PMD.EOL +
    409             "   }" + PMD.EOL +
    410             "  }" + PMD.EOL +
    411             " }" + PMD.EOL +
    412             " }";
    413
    414     private static final int[][] TEST15_NODES = {
    415         {1},
    416         {2},
    417         {3},
    418         {5, 7},
    419         {3},
    420         {6, 4},
    421         {4},
    422         {}
    423     };
    424     public static final String TEST15 =
    425             "public class Foo {" + PMD.EOL +
    426             " public void test_15() {" + PMD.EOL +
    427             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    428             "   if (i < 8) {" + PMD.EOL +
    429             "    i = 7;" + PMD.EOL +
    430             "   }" + PMD.EOL +
    431             "  }" + PMD.EOL +
    432             " }" + PMD.EOL +
    433             " }";
    434
    435     private static final int[][] TEST16_NODES = {
    436         {1},
    437         {2},
    438         {3},
    439         {5, 8},
    440         {3},
    441         {6, 7},
    442         {4},
    443         {4},
    444         {}
    445     };
    446     public static final String TEST16 =
    447             "public class Foo {" + PMD.EOL +
    448             " public void test_16() {" + PMD.EOL +
    449             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    450             "   if (i < 8) {" + PMD.EOL +
    451             "    i = 7;" + PMD.EOL +
    452             "   } else {" + PMD.EOL +
    453             "    i = 6;" + PMD.EOL +
    454             "   }" + PMD.EOL +
    455             "  }" + PMD.EOL +
    456             " }" + PMD.EOL +
    457             " }";
    458
    459     private static final int[][] TEST17_NODES = {
    460         {1},
    461         {2},
    462         {3},
    463         {5, 10},
    464         {3},
    465         {6, 7},
    466         {4},
    467         {8, 9},
    468         {4},
    469         {4},
    470         {}
    471     };
    472     public static final String TEST17 =
    473             "public class Foo {" + PMD.EOL +
    474             " public void test_17() {" + PMD.EOL +
    475             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    476             "   if (i < 6) {" + PMD.EOL +
    477             "    i = 7;" + PMD.EOL +
    478             "   } else if (i > 8) {" + PMD.EOL +
    479             "    i = 9;" + PMD.EOL +
    480             "   } else {" + PMD.EOL +
    481             "    i = 10;" + PMD.EOL +
    482             "   }" + PMD.EOL +
    483             "  }" + PMD.EOL +
    484             " }" + PMD.EOL +
    485             " }";
    486
    487     private static final int[][] TEST18_NODES = {
    488         {1},
    489         {2},
    490         {3},
    491         {5, 9},
    492         {3},
    493         {6},
    494         {8, 4},
    495         {6},
    496         {7},
    497         {}
    498     };
    499     public static final String TEST18 =
    500             "public class Foo {" + PMD.EOL +
    501             " public void test_18() {" + PMD.EOL +
    502             "  for (int i = 0; i < 0; i++) {" + PMD.EOL +
    503             "   for (int j = 0; j < 0; j++) {" + PMD.EOL +
    504             "    j++;" + PMD.EOL +
    505             "   }" + PMD.EOL +
    506             "  }" + PMD.EOL +
    507             " }" + PMD.EOL +
    508             " }";
    509
    510     private static final int[][] TEST19_NODES = {
    511         {1},
    512         {2},
    513         {3},
    514         {4, 5},
    515         {10},
    516         {6, 7},
    517         {10},
    518         {8, 9},
    519         {10},
    520         {10},
    521         {}
    522     };
    523     public static final String TEST19 =
    524             "public class Foo {" + PMD.EOL +
    525             " public void test_19() {" + PMD.EOL +
    526             "  int i = 0;" + PMD.EOL +
    527             "  if (i == 1) {" + PMD.EOL +
    528             "   i = 2;" + PMD.EOL +
    529             "  } else if (i == 3) {" + PMD.EOL +
    530             "   i = 4;" + PMD.EOL +
    531             "  } else if (i == 5) {" + PMD.EOL +
    532             "   i = 6;" + PMD.EOL +
    533             "  } else {" + PMD.EOL +
    534             "   i = 7;" + PMD.EOL +
    535             "  }" + PMD.EOL +
    536             " }" + PMD.EOL +
    537             " }";
    538
    539     private static final int[][] TEST20_NODES = {
    540         {1},
    541         {2},
    542         {3},
    543         {4, 6},
    544         {5, 7},
    545         {7},
    546         {7},
    547         {}
    548     };
    549     public static final String TEST20 =
    550             "public class Foo {" + PMD.EOL +
    551             " public void test_20() {" + PMD.EOL +
    552             "  int i = 0;" + PMD.EOL +
    553             "  if (i == 1) {" + PMD.EOL +
    554             "   if (i == 2) {" + PMD.EOL +
    555             "    i = 3;" + PMD.EOL +
    556             "   }" + PMD.EOL +
    557             "  } else {" + PMD.EOL +
    558             "   i = 7;" + PMD.EOL +
    559             "  }" + PMD.EOL +
    560             " }" + PMD.EOL +
    561             " }";
    562
    563     private static final int[][] TEST21_NODES = {
    564         {1},
    565         {2},
    566         {3},
    567         {4, 9},
    568         {5},
    569         {7, 8},
    570         {5},
    571         {6},
    572         {11},
    573         {10, 11},
    574         {11},
    575         {}
    576     };
    577     public static final String TEST21 =
    578             "public class Foo {" + PMD.EOL +
    579             " public void test_21() {" + PMD.EOL +
    580             "  int i = 0;" + PMD.EOL +
    581             "  if (i == 1) {" + PMD.EOL +
    582             "   for (i = 3; i < 4; i++) {" + PMD.EOL +
    583             "    i = 5;" + PMD.EOL +
    584             "   }" + PMD.EOL +
    585             "   i++;" + PMD.EOL +
    586             "  } else if (i < 6) {" + PMD.EOL +
    587             "   i = 7;" + PMD.EOL +
    588             "  }" + PMD.EOL +
    589             " }" + PMD.EOL +
    590             " }";
    591
    592     private static final int[][] TEST22_NODES = {
    593         {1},
    594         {2},
    595         {3},
    596         {4, 8},
    597         {5},
    598         {7, 9},
    599         {5},
    600         {6},
    601         {9},
    602         {}
    603     };
    604     public static final String TEST22 =
    605             "public class Foo {" + PMD.EOL +
    606             " public void test_22() {" + PMD.EOL +
    607             "  int i = 0;" + PMD.EOL +
    608             "  if (i == 1) {" + PMD.EOL +
    609             "   for (i = 3; i < 4; i++) {" + PMD.EOL +
    610             "    i = 5;" + PMD.EOL +
    611             "   }" + PMD.EOL +
    612             "  } else {" + PMD.EOL +
    613             "   i = 7;" + PMD.EOL +
    614             "  }" + PMD.EOL +
    615             " }" + PMD.EOL +
    616             " }";
    617
    618     private static final int[][] TEST23_NODES = {
    619         {1},
    620         {2},
    621         {3},
    622         {4, 8},
    623         {5},
    624         {7, 10},
    625         {5},
    626         {6},
    627         {9, 10},
    628         {10},
    629         {}
    630     };
    631     public static final String TEST23 =
    632             "public class Foo {" + PMD.EOL +
    633             " public void test_23() {" + PMD.EOL +
    634             "  int i = 0;" + PMD.EOL +
    635             "  if (i == 1) {" + PMD.EOL +
    636             "   for (i = 3; i < 4; i++) {" + PMD.EOL +
    637             "    i = 5;" + PMD.EOL +
    638             "   }" + PMD.EOL +
    639             "  } else if (i < 6) {" + PMD.EOL +
    640             "   i = 7;" + PMD.EOL +
    641             "  }" + PMD.EOL +
    642             " }" + PMD.EOL +
    643             " }";
    644
    645     private static final int[][] TEST24_NODES = {
    646         {1},
    647         {2},
    648         {3},
    649         {4, 9},
    650         {5},
    651         {7, 11},
    652         {5},
    653         {8, 6},
    654         {6},
    655         {10, 11},
    656         {11},
    657         {}
    658     };
    659     public static final String TEST24 =
    660             "public class Foo {" + PMD.EOL +
    661             " public void test_24() {" + PMD.EOL +
    662             "  int x = 0;" + PMD.EOL +
    663             "  if (x > 2) {" + PMD.EOL +
    664             "   for (int i = 0; i < 1; i++) {" + PMD.EOL +
    665             "    if (x > 3) {" + PMD.EOL +
    666             "     x++;" + PMD.EOL +
    667             "    }" + PMD.EOL +
    668             "   }" + PMD.EOL +
    669             "  } else if (x > 4) {" + PMD.EOL +
    670             "   x++;" + PMD.EOL +
    671             "  }" + PMD.EOL +
    672             " }" + PMD.EOL +
    673             " }";
    674
    675     private static final int[][] TEST25_NODES = {
    676         {1},
    677         {2},
    678         {3},
    679         {4, 5},
    680         {5},
    681         {}
    682     };
    683     public static final String TEST25 =
    684             "public class Foo {" + PMD.EOL +
    685             " public void test_25() {" + PMD.EOL +
    686             "  int x = 0;" + PMD.EOL +
    687             "  switch (x) {" + PMD.EOL +
    688             "   default:" + PMD.EOL +
    689             "    x = 9;" + PMD.EOL +
    690             "  }" + PMD.EOL +
    691             " }" + PMD.EOL +
    692             " }";
    693
    694     private static final int[][] TEST26_NODES = {
    695         {1},
    696         {2},
    697         {3},
    698         {4},
    699         {5, 6},
    700         {6},
    701         {7},
    702         {8, 3},
    703         {9},
    704         {}
    705     };
    706     public static final String TEST26 =
    707             "public class Foo {" + PMD.EOL +
    708             " public void test_26() {" + PMD.EOL +
    709             "  int x = 0;" + PMD.EOL +
    710             "  do {" + PMD.EOL +
    711             "   if (x > 0) {" + PMD.EOL +
    712             "    x++;" + PMD.EOL +
    713             "   }" + PMD.EOL +
    714             "   x++;" + PMD.EOL +
    715             "  } while (x < 9);" + PMD.EOL +
    716             "  x++;" + PMD.EOL +
    717             " }" + PMD.EOL +
    718             " }";
    719
    720     private static final int[][] TEST27_NODES = {
    721         {1},
    722         {2},
    723         {3},
    724         {5, 9},
    725         {3},
    726         {6},
    727         {7},
    728         {8},
    729         {6, 4},
    730         {}
    731     };
    732     public static final String TEST27 =
    733             "public class Foo {" + PMD.EOL +
    734             " public void test_27() {" + PMD.EOL +
    735             "  for (int i = 0; i < 36; i++) {" + PMD.EOL +
    736             "   int x = 0;" + PMD.EOL +
    737             "   do {" + PMD.EOL +
    738             "    x++;" + PMD.EOL +
    739             "   } while (x < 9);" + PMD.EOL +
    740             "  }" + PMD.EOL +
    741             " }" + PMD.EOL +
    742             " }";
    743
    744     private static final int[][] TEST28_NODES = {
    745         {1},
    746         {2},
    747         {3},
    748         {5, 14},
    749         {3},
    750         {6},
    751         {7},
    752         {8, 12},
    753         {9},
    754         {10, 12},
    755         {11},
    756         {12},
    757         {13},
    758         {6, 4},
    759         {}
    760     };
    761     public static final String TEST28 =
    762             "public class Foo {" + PMD.EOL +
    763             " private void test_28() {" + PMD.EOL +
    764             "  for (int i = 0; i < 36; i++) {" + PMD.EOL +
    765             "   int x = 0;" + PMD.EOL +
    766             "   do {" + PMD.EOL +
    767             "    if (x > 0) {" + PMD.EOL +
    768             "     x++;" + PMD.EOL +
    769             "     switch (i) {" + PMD.EOL +
    770             "      case 0:" + PMD.EOL +
    771             "       x = 0;" + PMD.EOL +
    772             "       break;" + PMD.EOL +
    773             "     }" + PMD.EOL +
    774             "    }" + PMD.EOL +
    775             "    x++;" + PMD.EOL +
    776             "   } while (x < 9);" + PMD.EOL +
    777             "  }" + PMD.EOL +
    778             " }" + PMD.EOL +
    779             " }";
    780
    781     private static final int[][] TEST29_NODES = {
    782         {1},
    783         {2},
    784         {3, 4, 5},
    785         {6},
    786         {6},
    787         {6},
    788         {}
    789
    790     };
    791     public static final String TEST29 =
    792             "public class Foo {" + PMD.EOL +
    793             " private void test_29() {" + PMD.EOL +
    794             "  switch(x) {" + PMD.EOL +
    795             "   case 1:" + PMD.EOL +
    796             "    break; " + PMD.EOL +
    797             "   default: " + PMD.EOL +
    798             "    break;" + PMD.EOL +
    799             "   case 2:" + PMD.EOL +
    800             "    break;" + PMD.EOL +
    801             "  }" + PMD.EOL +
    802             " }" + PMD.EOL +
    803             "}";
    804
    805     private static final int[][] TEST30_NODES = {
    806         {1},
    807         {2},
    808         {3},
    809         {4, 7},
    810         {5, 6},
    811         {4},
    812         {3},
    813         {}
    814     };
    815     public static final String TEST30 =
    816             "public class Foo {" + PMD.EOL +
    817             " private void test_30() {" + PMD.EOL +
    818             "  int x = 0;" + PMD.EOL +
    819             "  while (true) {" + PMD.EOL +
    820             "   while (x>0) {" + PMD.EOL +
    821             "     x++;" + PMD.EOL +
    822             "   }" + PMD.EOL +
    823             "   continue;" + PMD.EOL +
    824             "  }" + PMD.EOL +
    825             " }" + PMD.EOL +
    826             "}";
    827
    828     public static junit.framework.Test suite() {
    829         return new junit.framework.JUnit4TestAdapter(AcceptanceTest.class);
    830     }
    831 }