1 package integrationTests;
2
3
4
5
6 @SuppressWarnings("ControlFlowStatementWithoutBraces")
7 public final class IfElseStatements {
8
9
10
11
12
13
14
15 void simpleIf(boolean b) {
16 if (b) {
17 System.gc();
18 System.runFinalization();
19 }
20 }
21
22
23
24
25
26
27
28 void ifAndElse(boolean b) {
29 if (b) {
30 System.gc();
31 } else {
32 System.runFinalization();
33 }
34 }
35
36
37
38
39
40
41
42 void singleLineIf(boolean b) {
43
44 if (b) { System.gc(); }
45
46 }
47
48
49
50
51
52
53
54 void singleLineIfAndElse(boolean b) {
55
56 if (b) { System.gc(); } else { System.runFinalization(); }
57
58 }
59
60
61
62
63
64
65
66
67
68 void methodWithFourDifferentPathsAndSimpleLines(boolean b, int i) {
69 if (b) {
70 System.gc();
71 } else {
72 System.runFinalization();
73 }
74
75 if (i > 0) {
76 System.gc();
77 }
78 }
79
80
81
82
83
84
85
86
87
88 void methodWithFourDifferentPathsAndSegmentedLines(boolean b, int i) {
89 if (b) {
90 System.gc();
91 } else {
92 System.runFinalization();
93 }
94
95 if (i > 0) {
96 System.gc();
97 } else {
98 System.runFinalization();
99 }
100 }
101
102
103
104
105
106
107
108
109
110
111
112 boolean ifElseWithComplexBooleanCondition(boolean a, boolean b) {
113
114 if (a || b) {
115 return true;
116 }
117 return false;
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135 @SuppressWarnings({ "AssignmentToMethodParameter" })
136 int returnInput(int x, boolean a, boolean b, boolean c) {
137 if (a) {
138 x++;
139 }
140
141 if (b) {
142 x--;
143 }
144
145 if (c) {
146
147 x = x;
148 }
149
150 return x;
151 }
152
153
154
155
156
157
158
159
160
161
162
163 int nestedIf(boolean a, boolean b) {
164 int i = 1;
165
166 if (a && b) {
167 i = 2;
168 }
169
170 return i;
171 }
172
173
174
175
176
177
178
179
180
181
182
183 int ifElseWithNestedIf(boolean a, boolean b) {
184 int i = 1;
185
186 if (!a) {
187 return 3;
188 }
189 if (b) {
190 i = 2;
191 }
192
193 return i;
194 }
195
196
197
198
199
200
201
202
203
204
205
206 int nestedIfElse(boolean a, boolean b) {
207 int i = 1;
208
209 if (a) {
210 if (b) {
211 i = 2;
212 } else {
213 i = 3;
214 }
215 } else if (b) {
216 i = 4;
217 }
218
219 return i;
220 }
221
222
223
224
225
226
227
228 void infeasiblePaths(boolean a) {
229 if (a) {
230 System.gc();
231 }
232
233 if (a) {
234 System.runFinalization();
235 }
236 }
237
238
239
240
241
242
243
244
245
246 int anotherSingleLineIfAndElse(boolean b) {
247
248 int r; if (b) { r = 1; } else { r = 2; } return r;
249
250 }
251
252
253
254
255
256
257
258
259
260 int yetAnotherSingleLineIfAndElse(boolean b) {
261
262 if (b) { return 1; } return 2;
263
264 }
265
266
267
268
269
270
271
272
273
274 void ifWithBooleanAndOperator(boolean b1, boolean b2) {
275 if (b1 && b2) {
276 System.gc();
277 }
278 }
279
280
281
282
283
284
285
286
287
288 void ifWithBooleanOrOperator(boolean b1, boolean b2) {
289 if (b1 || b2) {
290 System.gc();
291 }
292 }
293
294
295
296
297
298
299
300
301
302 void anotherIfWithBooleanAndOperator(boolean b1, boolean b2) {
303 if (b1 && b2) {
304 System.gc();
305 }
306 }
307
308
309
310
311
312
313
314
315
316 void ifSpanningMultipleLines(boolean b, int i) {
317
318 if (
319 b ||
320 i > 0
321 ) {
322 System.gc();
323 }
324
325 }
326
327
328
329
330
331
332
333
334
335 ClassLoader methodToBeCalledFromCustomRunnerTest(String s) {
336 instanceField = s;
337
338 if (s.isEmpty()) {
339 return null;
340 }
341
342 return getClass().getClassLoader();
343 }
344
345
346 String instanceField;
347 }