1
2
3
4
5
6
7 package const0
8
9 import "unsafe"
10
11
12 var x = 0
13 const c0 = x
14
15
16 const _ interface {} = 0
17
18 func _ () {
19 const _ interface {} = 0
20 for i := 0; i < 10; i++ {}
21 }
22
23
24 const (
25
26 ub0 = false
27 ub1 = true
28 ub2 = 2 < 1
29 ub3 = ui1 == uf1
30 ub4 = true == 0
31
32
33 ui0 = 0
34 ui1 = 1
35 ui2 = 42
36 ui3 = 3141592653589793238462643383279502884197169399375105820974944592307816406286
37 ui4 = -10
38
39 ui5 = ui0 + ui1
40 ui6 = ui1 - ui1
41 ui7 = ui2 * ui1
42 ui8 = ui3 / ui3
43 ui9 = ui3 % ui3
44
45 ui10 = 1 / 0
46 ui11 = ui1 / 0
47 ui12 = ui3 / ui0
48 ui13 = 1 % 0
49 ui14 = ui1 % 0
50 ui15 = ui3 % ui0
51
52 ui16 = ui2 & ui3
53 ui17 = ui2 | ui3
54 ui18 = ui2 ^ ui3
55 ui19 = 1 % 1.0
56
57
58 uf0 = 0.
59 uf1 = 1.
60 uf2 = 4.2e1
61 uf3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
62 uf4 = 1e-1
63
64 uf5 = uf0 + uf1
65 uf6 = uf1 - uf1
66 uf7 = uf2 * uf1
67 uf8 = uf3 / uf3
68 uf9 = uf3 % uf3
69
70 uf10 = 1 / 0
71 uf11 = uf1 / 0
72 uf12 = uf3 / uf0
73
74 uf16 = uf2 & uf3
75 uf17 = uf2 | uf3
76 uf18 = uf2 ^ uf3
77
78
79 uc0 = 0.i
80 uc1 = 1.i
81 uc2 = 4.2e1i
82 uc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i
83 uc4 = 1e-1i
84
85 uc5 = uc0 + uc1
86 uc6 = uc1 - uc1
87 uc7 = uc2 * uc1
88 uc8 = uc3 / uc3
89 uc9 = uc3 % uc3
90
91 uc10 = 1 / 0
92 uc11 = uc1 / 0
93 uc12 = uc3 / uc0
94
95 uc16 = uc2 & uc3
96 uc17 = uc2 | uc3
97 uc18 = uc2 ^ uc3
98 )
99
100 type (
101 mybool bool
102 myint int
103 myfloat float64
104 mycomplex complex128
105 )
106
107
108 const (
109
110 tb0 bool = false
111 tb1 bool = true
112 tb2 mybool = 2 < 1
113 tb3 mybool = ti1 == tf1
114
115
116 ti0 int8 = ui0
117 ti1 int32 = ui1
118 ti2 int64 = ui2
119 ti3 myint = ui3
120 ti4 myint = ui4
121
122 ti5 = ti0 + ti1
123 ti6 = ti1 - ti1
124 ti7 = ti2 * ti1
125 ti8 = ti3 / ti3
126 ti9 = ti3 % ti3
127
128 ti10 = 1 / 0
129 ti11 = ti1 / 0
130 ti12 = ti3 / ti0
131 ti13 = 1 % 0
132 ti14 = ti1 % 0
133 ti15 = ti3 % ti0
134
135 ti16 = ti2 & ti3
136 ti17 = ti2 | ti4
137 ti18 = ti2 ^ ti5
138
139
140 tf0 float32 = 0.
141 tf1 float32 = 1.
142 tf2 float64 = 4.2e1
143 tf3 myfloat = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
144 tf4 myfloat = 1e-1
145
146 tf5 = tf0 + tf1
147 tf6 = tf1 - tf1
148 tf7 = tf2 * tf1
149 tf8 = tf3 / tf3
150 tf9 = tf3 % tf3
151
152 tf10 = 1 / 0
153 tf11 = tf1 / 0
154 tf12 = tf3 / tf0
155
156 tf16 = tf2 & tf3
157 tf17 = tf2 | tf3
158 tf18 = tf2 ^ tf3
159
160
161 tc0 = 0.i
162 tc1 = 1.i
163 tc2 = 4.2e1i
164 tc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i
165 tc4 = 1e-1i
166
167 tc5 = tc0 + tc1
168 tc6 = tc1 - tc1
169 tc7 = tc2 * tc1
170 tc8 = tc3 / tc3
171 tc9 = tc3 % tc3
172
173 tc10 = 1 / 0
174 tc11 = tc1 / 0
175 tc12 = tc3 / tc0
176
177 tc16 = tc2 & tc3
178 tc17 = tc2 | tc3
179 tc18 = tc2 ^ tc3
180 )
181
182
183 const (
184 a = a
185 b , c , d, e = e, d, c, b
186 f float64 = d
187 )
188
189
190 const (
191 a1, a2, a3 = 7, 3.1415926, "foo"
192 b1, b2, b3 = b3, b1, 42
193 c1, c2, c3 = 1, 2
194 d1, d2, d3 = 1, 2, 3, 4
195 _p0 = assert(a1 == 7)
196 _p1 = assert(a2 == 3.1415926)
197 _p2 = assert(a3 == "foo")
198 _p3 = assert(b1 == 42)
199 _p4 = assert(b2 == 42)
200 _p5 = assert(b3 == 42)
201 )
202
203 func _() {
204 const (
205 a1, a2, a3 = 7, 3.1415926, "foo"
206 b1, b2, b3 = b3, b1, 42
207 c1, c2, c3 = 1, 2
208 d1, d2, d3 = 1, 2, 3, 4
209 _p0 = assert(a1 == 7)
210 _p1 = assert(a2 == 3.1415926)
211 _p2 = assert(a3 == "foo")
212 _p3 = assert(b1 == 42)
213 _p4 = assert(b2 == 42)
214 _p5 = assert(b3 == 42)
215 )
216 }
217
218
219 const (
220 iota0 = iota
221 iota1 = iota
222 iota2 = iota*2
223 _a0 = assert(iota0 == 0)
224 _a1 = assert(iota1 == 1)
225 _a2 = assert(iota2 == 4)
226 iota6 = iota*3
227
228 iota7
229 iota8
230 _a3 = assert(iota7 == 21)
231 _a4 = assert(iota8 == 24)
232 )
233
234 const (
235 _b0 = iota
236 _b1 = assert(iota + iota2 == 5)
237 _b2 = len([iota]int{})
238 _b3 = assert(_b2 == 2)
239 _b4 = len(A{})
240 )
241
242 type A [iota ]int
243
244
245
246 const (
247 _c0 = iota
248 _c1
249 _c2
250 _x = _c2 + _d1 + _e0
251 )
252
253 const (
254 _d0 = iota
255 _d1
256 )
257
258 const (
259 _e0 = iota
260 )
261
262 var _ = assert(_x == 3)
263
264
265 const (
266 _n0 = nil
267 _n1 = [ ]int{}
268 )
269
270
271 type _ [iota ]byte
272 var _ = iota
273 func _() {
274 _ = iota
275 const _ = iota
276 _ = iota
277 }
278
279 func _() {
280 iota := 123
281 const x = iota
282 var y = iota
283 _ = y
284 }
285
286
287 const (
288 _ = iota
289 _ = len([iota]byte{})
290 _ = unsafe.Sizeof(iota)
291 _ = unsafe.Sizeof(func() { _ = iota })
292 _ = unsafe.Sizeof(func() { var _ = iota })
293 _ = unsafe.Sizeof(func() { const _ = iota })
294 _ = unsafe.Sizeof(func() { type _ [iota]byte })
295 _ = unsafe.Sizeof(func() { func() int { return iota }() })
296 )
297
298
299 const (
300 zero = iota
301 one = iota
302 _ = unsafe.Sizeof(func() {
303 var x [iota]int
304 const (
305 Zero = iota
306 One
307 Two
308 _ = unsafe.Sizeof([iota-1]int{} == x)
309 _ = unsafe.Sizeof([Two]int{} == x)
310 )
311 var z [iota]int
312 _ = unsafe.Sizeof([2]int{} == z)
313 })
314 three = iota
315 )
316 var _ [three]int = [3]int{}
317
318 var (
319 _ = iota
320 _ = unsafe.Sizeof(iota )
321 _ = unsafe.Sizeof(func() { _ = iota })
322 _ = unsafe.Sizeof(func() { var _ = iota })
323 _ = unsafe.Sizeof(func() { type _ [iota ]byte })
324 _ = unsafe.Sizeof(func() { func() int { return iota }() })
325 )
326
327
328 var _ = []int64{
329 0.0005 * 1e9,
330 0.001 * 1e9,
331 0.005 * 1e9,
332 0.01 * 1e9,
333 0.05 * 1e9,
334 0.1 * 1e9,
335 0.5 * 1e9,
336 1 * 1e9,
337 5 * 1e9,
338 }
339
340 const _ = unsafe.Sizeof(func() {
341 const _ = 0
342 _ = iota
343
344 const (
345 zero = iota
346 one
347 )
348 assert(one == 1)
349 assert(iota == 0)
350 })
351
352
353 const i1 = iota
354 const i2 = iota
355 const i3 = iota
356
357 func _() {
358 assert(i1 == 0)
359 assert(i2 == 0)
360 assert(i3 == 0)
361
362 const i4 = iota
363 const i5 = iota
364 const i6 = iota
365
366 assert(i4 == 0)
367 assert(i5 == 0)
368 assert(i6 == 0)
369 }
370
371
372 const prec = 512
373 const maxInt = (1<<(prec/2) - 1) * (1<<(prec/2) + 1)
374
375 const _ = maxInt + 1
376 const _ = -maxInt - 1
377 const _ = maxInt ^ -1
378 const _ = maxInt * 2
379 const _ = maxInt << 2
380 const _ = 1 << prec
381
382 const _ = ^ maxInt
383
View as plain text