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