1 package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
2
3
4
5
6
7
8
9
10
11 class InputFormattedWhitespaceAroundBasic {
12 private final int var1 = 1;
13 private final int var2 = 1;
14
15
16 private final int var3 = 1;
17
18
19 private final int var4 = 1;
20
21 int xyz;
22 int abc;
23 int pqr;
24
25
26 private int test;
27
28 private int i4;
29 private int i5;
30 private int i6;
31
32
33 void method1() {
34 final int a = 1;
35 int b = 1;
36 b = 1;
37 b += 1;
38 b -= -1 + (+b);
39 b = b++ + b--;
40 b = ++b - --b;
41 }
42
43
44 void method2() {
45 synchronized (this) {
46 }
47 try {
48
49 } catch (RuntimeException e) {
50
51 }
52 }
53
54
55 private void fastExit() {
56 boolean complicatedStuffNeeded = true;
57 if (!complicatedStuffNeeded) {
58
59 } else {
60
61 }
62 }
63
64
65
66
67
68
69 private int nonVoid() {
70 if (true) {
71 return (2);
72 } else {
73 return 2;
74 }
75 }
76
77
78 private void testCasts() {
79 Object o = (Object) new Object();
80 o = (Object) o;
81 o = (Object) o;
82 o = (Object) o;
83 }
84
85
86 private void testQuestions() {
87
88 boolean b = (1 == 2) ? false : true;
89 }
90
91
92 private void starTest() {
93 int x = 2 * 3 * 4;
94 }
95
96
97 private void boolTest() {
98 boolean a = true;
99 boolean x = !a;
100 int z = ~1 + ~2;
101 }
102
103
104 private void divTest() {
105 int a = 4 % 2;
106 int b = 4 % 2;
107 int c = 4 % 2;
108 int d = 4 % 2;
109 int e = 4 / 2;
110 int f = 4 / 2;
111 int g = 4 / 2;
112 }
113
114
115
116
117
118
119 private String dotTest() {
120 Object o = new Object();
121 o.toString();
122 o.toString();
123 o.toString();
124 return o.toString();
125 }
126
127
128 public void assertTest() {
129
130 assert true;
131
132
133 assert true : "Whups";
134
135
136 assert "OK".equals(null) ? false : true : "Whups";
137
138
139 assert (true);
140
141
142 assert true : "Whups";
143 }
144
145
146 void donBradman(Runnable run) {
147 donBradman(
148 new Runnable() {
149 public void run() {}
150 });
151
152 final Runnable r =
153 new Runnable() {
154 public void run() {}
155 };
156 }
157
158
159 void rfe521323() {
160 doStuff();
161 for (int i = 0; i < 5; i++) {}
162 }
163
164
165 void bug806243() {
166 Object o =
167 new InputFormattedWhitespaceAroundBasic() {
168 private int test;
169 };
170 }
171
172 void doStuff() {}
173
174 interface Foo {
175 void foo();
176 }
177
178
179
180
181
182
183
184 class SpecialCasesInForLoop {
185 void forIterator() {
186
187 for (int i = 0; i++ < 5; ) {
188
189 }
190
191
192
193 int i = 0;
194 for (; i < 5; i++) {
195
196 }
197 for (int anInt : getSomeInts()) {
198
199 }
200 }
201
202 int[] getSomeInts() {
203 int i = 2 / 3;
204 return null;
205 }
206
207 void forColon() {
208 int[] ll = new int[10];
209 for (int x : ll) {}
210 for (int x : ll) {}
211 for (int x : ll) {}
212 for (int x : ll) {}
213 }
214 }
215
216
217 class NewGoogleOperators {
218 NewGoogleOperators() {
219 Runnable l;
220
221 l = () -> {};
222 l = () -> {};
223 l = () -> {};
224 l = () -> {};
225
226 java.util.Arrays.sort(null, String::compareToIgnoreCase);
227 java.util.Arrays.sort(null, String::compareToIgnoreCase);
228
229 new Object().toString();
230 new Object().toString();
231 }
232 }
233 }