-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathLogic.java
More file actions
67 lines (60 loc) · 1.21 KB
/
Logic.java
File metadata and controls
67 lines (60 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public class Logic {
boolean g(int i) {
return i < 2;
}
void f(int[] a, String s) {
boolean b =
((g(1)) ?
g(2) :
true);
if (b != false) {
} else {
}
int sz = a != null ? a.length : 0;
for (int i = 0; i < sz; i++) {
int e = a[i];
if (e > 2) break;
}
if (g(3))
s = "bar";
switch (s) {
case "bar":
break;
case "foo":
break;
default:
break;
}
Object o = g(4) ? null : s;
if (o instanceof String) {
}
}
void f2(int i) {
checkTrue(i > 0, "i pos");
checkFalse(g(100), "g");
if (i > 10) {
checkTrue(i > 20, "");
}
int dummy = 0;
}
private static void checkTrue(boolean b, String msg) {
if (!b) throw new Error (msg);
}
private static void checkFalse(boolean b, String msg) {
checkTrue(!b, msg);
}
void f3(int i) {
checkTrue("i pos", i > 0);
checkFalse("g", g(100));
if (i > 10) {
checkTrue("", i > 20);
}
int dummy = 0;
}
private static void checkTrue(String msg, boolean b) {
if (!b) throw new Error (msg);
}
private static void checkFalse(String msg, boolean b) {
checkTrue(!b, msg);
}
}