• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / jmockit1 / 496

15 Nov 2025 05:33PM UTC coverage: 72.192% (-0.008%) from 72.2%
496

push

github

web-flow
Merge pull request #412 from hazendaz/renovate/major-spring-core

Update spring core to v7 (major)

5677 of 8360 branches covered (67.91%)

Branch coverage included in aggregate %.

11922 of 16018 relevant lines covered (74.43%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/coverageTests/src/main/java/integration/tests/IfElseStatements.java
1
/*
2
 * MIT License
3
 * Copyright (c) 2006-2025 JMockit developers
4
 * See LICENSE file for full license text.
5
 */
6
package integration.tests;
7

8
/**
9
 * The Class IfElseStatements.
10
 */
11
@SuppressWarnings("ControlFlowStatementWithoutBraces")
12
public final class IfElseStatements {
1✔
13

14
    /**
15
     * Simple if.
16
     *
17
     * @param b
18
     *            the b
19
     */
20
    void simpleIf(boolean b) {
21
        if (b) {
1✔
22
            System.gc();
1✔
23
            System.runFinalization();
1✔
24
        }
25
    }
1✔
26

27
    /**
28
     * If and else.
29
     *
30
     * @param b
31
     *            the b
32
     */
33
    void ifAndElse(boolean b) {
34
        if (b) {
1✔
35
            System.gc();
1✔
36
        } else {
37
            System.runFinalization();
1✔
38
        }
39
    }
1✔
40

41
    /**
42
     * Single line if.
43
     *
44
     * @param b
45
     *            the b
46
     */
47
    void singleLineIf(boolean b) {
48
        // @formatter:off
49
        if (b) { System.gc(); }
1✔
50
        // @formatter:on
51
    }
1✔
52

53
    /**
54
     * Single line if and else.
55
     *
56
     * @param b
57
     *            the b
58
     */
59
    void singleLineIfAndElse(boolean b) {
60
        // @formatter:off
61
        if (b) { System.gc(); } else { System.runFinalization(); }
1✔
62
        // @formatter:on
63
    }
1✔
64

65
    /**
66
     * Method with four different paths and simple lines.
67
     *
68
     * @param b
69
     *            the b
70
     * @param i
71
     *            the i
72
     */
73
    void methodWithFourDifferentPathsAndSimpleLines(boolean b, int i) {
74
        if (b) {
1✔
75
            System.gc();
1✔
76
        } else {
77
            System.runFinalization();
1✔
78
        }
79

80
        if (i > 0) {
1✔
81
            System.gc();
1✔
82
        }
83
    }
1✔
84

85
    /**
86
     * Method with four different paths and segmented lines.
87
     *
88
     * @param b
89
     *            the b
90
     * @param i
91
     *            the i
92
     */
93
    void methodWithFourDifferentPathsAndSegmentedLines(boolean b, int i) {
94
        if (b) {
1✔
95
            System.gc();
1✔
96
        } else {
97
            System.runFinalization();
1✔
98
        }
99

100
        if (i > 0) {
1✔
101
            System.gc();
1✔
102
        } else {
103
            System.runFinalization();
1✔
104
        }
105
    }
1✔
106

107
    /**
108
     * If else with complex boolean condition.
109
     *
110
     * @param a
111
     *            the a
112
     * @param b
113
     *            the b
114
     *
115
     * @return true, if successful
116
     */
117
    boolean ifElseWithComplexBooleanCondition(boolean a, boolean b) {
118
        // noinspection RedundantIfStatement
119
        if (a || b) {
1!
120
            return true;
1✔
121
        }
122
        return false;
×
123
    }
124

125
    /**
126
     * Return input.
127
     *
128
     * @param x
129
     *            the x
130
     * @param a
131
     *            the a
132
     * @param b
133
     *            the b
134
     * @param c
135
     *            the c
136
     *
137
     * @return the int
138
     */
139
    // Must return the same value of x as it was called with. Some paths will fail that requirement.
140
    @SuppressWarnings({ "AssignmentToMethodParameter" })
141
    int returnInput(int x, boolean a, boolean b, boolean c) {
142
        if (a) {
1✔
143
            x++;
1✔
144
        }
145

146
        if (b) {
1✔
147
            x--;
1✔
148
        }
149

150
        if (c) {
1✔
151
            // noinspection SillyAssignment
152
            x = x;
1✔
153
        }
154

155
        return x;
1✔
156
    }
157

158
    /**
159
     * Nested if.
160
     *
161
     * @param a
162
     *            the a
163
     * @param b
164
     *            the b
165
     *
166
     * @return the int
167
     */
168
    int nestedIf(boolean a, boolean b) {
169
        int i = 1;
1✔
170

171
        if (a && b) {
1!
172
            i = 2;
1✔
173
        }
174

175
        return i;
1✔
176
    }
177

178
    /**
179
     * If else with nested if.
180
     *
181
     * @param a
182
     *            the a
183
     * @param b
184
     *            the b
185
     *
186
     * @return the int
187
     */
188
    int ifElseWithNestedIf(boolean a, boolean b) {
189
        int i = 1;
1✔
190

191
        if (!a) {
1✔
192
            return 3;
1✔
193
        }
194
        if (b) {
1✔
195
            i = 2;
1✔
196
        }
197

198
        return i;
1✔
199
    }
200

201
    /**
202
     * Nested if else.
203
     *
204
     * @param a
205
     *            the a
206
     * @param b
207
     *            the b
208
     *
209
     * @return the int
210
     */
211
    int nestedIfElse(boolean a, boolean b) {
212
        int i = 1;
1✔
213

214
        if (a) {
1✔
215
            if (b) {
1✔
216
                i = 2;
1✔
217
            } else {
218
                i = 3;
1✔
219
            }
220
        } else if (b) {
1✔
221
            i = 4;
1✔
222
        }
223

224
        return i;
1✔
225
    }
226

227
    /**
228
     * Block comment with method signature: infeasiblePaths(boolean a).
229
     *
230
     * @param a
231
     *            the a
232
     */
233
    void infeasiblePaths(boolean a) {
234
        if (a) {
1✔
235
            System.gc();
1✔
236
        }
237

238
        if (a) {
1✔
239
            System.runFinalization();
1✔
240
        }
241
    }
1✔
242

243
    /**
244
     * Another single line if and else.
245
     *
246
     * @param b
247
     *            the b
248
     *
249
     * @return the int
250
     */
251
    int anotherSingleLineIfAndElse(boolean b) {
252
        // @formatter:off
253
        int r; if (b) { r = 1; } else { r = 2; } return r;
1!
254
        // @formatter:on
255
    }
256

257
    /**
258
     * Yet another single line if and else.
259
     *
260
     * @param b
261
     *            the b
262
     *
263
     * @return the int
264
     */
265
    int yetAnotherSingleLineIfAndElse(boolean b) {
266
        // @formatter:off
267
        if (b) { return 1; } return 2;
1✔
268
        // @formatter:on
269
    }
270

271
    /**
272
     * If with boolean and operator.
273
     *
274
     * @param b1
275
     *            the b 1
276
     * @param b2
277
     *            the b 2
278
     */
279
    void ifWithBooleanAndOperator(boolean b1, boolean b2) {
280
        if (b1 && b2) {
1!
281
            System.gc();
×
282
        }
283
    }
1✔
284

285
    /**
286
     * If with boolean or operator.
287
     *
288
     * @param b1
289
     *            the b 1
290
     * @param b2
291
     *            the b 2
292
     */
293
    void ifWithBooleanOrOperator(boolean b1, boolean b2) {
294
        if (b1 || b2) {
1!
295
            System.gc();
1✔
296
        }
297
    }
1✔
298

299
    /**
300
     * Another if with boolean and operator.
301
     *
302
     * @param b1
303
     *            the b 1
304
     * @param b2
305
     *            the b 2
306
     */
307
    void anotherIfWithBooleanAndOperator(boolean b1, boolean b2) {
308
        if (b1 && b2) {
×
309
            System.gc();
×
310
        }
311
    }
×
312

313
    /**
314
     * If spanning multiple lines.
315
     *
316
     * @param b
317
     *            the b
318
     * @param i
319
     *            the i
320
     */
321
    void ifSpanningMultipleLines(boolean b, int i) {
322
        // @formatter:off
323
        if (
1✔
324
           b ||
325
           i > 0
326
        ) {
327
            System.gc();
1✔
328
        }
329
        // @formatter:on
330
    }
1✔
331

332
    /**
333
     * Method to be called from custom runner test.
334
     *
335
     * @param s
336
     *            the s
337
     *
338
     * @return the class loader
339
     */
340
    ClassLoader methodToBeCalledFromCustomRunnerTest(String s) {
341
        instanceField = s;
×
342

343
        if (s.isEmpty()) {
×
344
            return null;
×
345
        }
346

347
        return getClass().getClassLoader();
×
348
    }
349

350
    /** The instance field. */
351
    String instanceField;
352
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc