View Javadoc

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