1 package integrationTests;
2
3
4
5
6 public final class BooleanExpressions {
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public boolean eval1(boolean x, boolean y, int z) {
21 return x && (y || z > 0);
22 }
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public boolean eval2(boolean x, boolean y, int z) {
37 return x && (y || z > 0);
38 }
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public boolean eval3(boolean x, boolean y, boolean z) {
53 return x && (y || z);
54 }
55
56
57
58
59
60
61
62
63
64
65
66
67
68 public boolean eval4(boolean x, boolean y, boolean z) {
69 return x && (!y || z);
70 }
71
72
73
74
75
76
77
78
79
80
81
82
83
84 public boolean eval5(boolean a, boolean b, boolean c) {
85 if (a) {
86 return true;
87 }
88 if (b || c) {
89 return false;
90 }
91
92 return !c;
93 }
94
95
96
97
98
99
100
101
102
103
104
105 static boolean isSameTypeIgnoringAutoBoxing(Class<?> firstType, Class<?> secondType) {
106 return firstType == secondType || firstType.isPrimitive() && isWrapperOfPrimitiveType(firstType, secondType)
107 || secondType.isPrimitive() && isWrapperOfPrimitiveType(secondType, firstType);
108 }
109
110
111
112
113
114
115
116
117
118
119
120 static boolean isWrapperOfPrimitiveType(Class<?> primitiveType, Class<?> otherType) {
121 return primitiveType == int.class && otherType == Integer.class
122 || primitiveType == long.class && otherType == Long.class
123 || primitiveType == double.class && otherType == Double.class
124 || primitiveType == float.class && otherType == Float.class
125 || primitiveType == boolean.class && otherType == Boolean.class;
126 }
127
128
129
130
131
132
133
134
135
136 public boolean simplyReturnsInput(boolean b) {
137 return b;
138 }
139
140
141
142
143
144
145
146
147
148 public boolean returnsNegatedInput(boolean b) {
149 return !b;
150 }
151
152
153
154
155
156
157
158
159
160
161
162 public boolean returnsTrivialResultFromInputAfterIfElse(boolean b, int i) {
163 String s;
164
165 if (b) {
166 s = "one";
167 } else {
168 s = "two";
169 }
170
171 return i != 0;
172 }
173
174
175
176
177
178
179
180
181
182
183
184 public boolean returnsResultPreviouslyComputedFromInput(boolean b, int i) {
185 String s = b ? "a" : "b";
186 boolean res;
187
188 if (i != 0) {
189 res = true;
190 } else {
191 res = false;
192 System.out.checkError();
193 }
194
195 return res;
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209
210 public boolean methodWithTooManyConditionsForPathAnalysis(int i, int j, boolean b) {
211 if (i > 0 && j < 5 || (b ? i > 1 : j > 5) || (i <= 3 || j >= 4) && b) {
212 return i + j == 3 == b;
213 }
214 if (i < 0 || j < 0) {
215 return i < j;
216 }
217
218 return b;
219 }
220
221
222
223
224
225
226
227
228
229 public boolean returnsNegatedInputFromLocalVariable(boolean b) {
230 return !b;
231 }
232 }