1 package test.net.sourceforge.pmd.rules.design;
2
3 import net.sourceforge.pmd.Rule;
4 import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
5
6 public class ConfusingTernaryRuleTest extends SimpleAggregatorTst {
7
8 private Rule rule;
9
10 public void setUp() {
11 rule = findRule("design", "ConfusingTernary");
12 }
13
14 public void testAll() {
15 runTests(rule);
16 }
17
18 /*
19 public class BadTernaries {
20 public static void main(String[] args) {
21 int i = 0;
22 int j = 1;
23 int k = 2;
24 boolean x = true;
25 boolean y = false;
26 boolean z = true;
27
28 // flag all of these, lines 11 - 42:
29 if (i != 11) {a();} else {b();}
30 if (i != 12 && j != 0) {a();} else {b();}
31 if (i != 13 || j != 0) {a();} else {b();}
32 if (i != 14 && j != 0 && k != 0) {a();} else {b();}
33 if (i != 15 || j != 0 || k != 0) {a();} else {b();}
34 if (i != 16) {a();} else if (i != j) {b();} else{c();}
35 if (i != 17) {a();} else if (i == j) {b();} else{c();}
36 if (i == 18) {a();} else if (i != j) {b();} else{c();}
37 x = (!y ? x : y);
38 x = (!(x && y) ? y : z);
39 x = (!(x || y) ? y : z);
40 x = ((!x && !y) ? y : z);
41 x = ((!x || !y) ? y : z);
42 if (i != 24 && !x) {a();} else {b();}
43 if (i != 25 || !x) {a();} else {b();}
44 if (i != 26 && j != 0 && !y) {a();} else {b();}
45 if (i != 27 || j != 0 || !y) {a();} else {b();}
46 if (i != 28) {a();} else if (!x) {b();} else{c();}
47 if (i != 29) {a();} else if (x) {b();} else{c();}
48 if (i == 30) {a();} else if (!x) {b();} else{c();}
49 x = !(c() == y) ? y : !z;
50 if (!c()) {a();} else {b();}
51 if (c() != x) {a();} else {b();}
52 if (!c() != x) {a();} else {b();}
53 if (!c() != !x) {a();} else {b();}
54 if ((i != 36) || !(j == 0)) {a();} else {b();}
55 if ((i != 37) || !(x ? y : z)) {a();} else {b();}
56 if ((i != 38)) {a();} else {b();}
57 if (i != 39 || (j != 0 || k != 0)) {a();} else {b();}
58 if (i != 40 && (j != 0 && k != 0)) {a();} else {b();}
59 if (!x && (j != 41 && k != 0)) {a();} else {b();}
60 if (((x != y)) || !(x)) { a(); } else { b(); }
61
62 // don't flag these:
63 if (i != 0) {a();}
64 if (!x) {a();}
65 if (i == 0) {a();} else {b();}
66 if (i == 0 && j != 0) {a();} else {b();}
67 if (i == 0 || j != 0) {a();} else {b();}
68 if (i == 0 && !x) {a();} else {b();}
69 if (x) {a();} else {b();}
70 if (x ? y : !z) {a();} else {b();}
71 if (c() == !x) {a();} else {b();}
72 if (c() ? !x : !c()) {a();} else {b();}
73 if (!x && d() instanceof String) {a();} else {b();}
74 if (!x && (d() instanceof String)) {a();} else {b();}
75 }
76
77 private static void a() { }
78 private static void b() { }
79 private static boolean c() { return true; }
80 private static Object d() { return null; }
81 }
82
83 */
84
85 }