2018-01-24 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / go.test / test / iota.go
blob7187dbe335ea42f03ea44942782398b49d45027b
1 // run
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test iota.
9 package main
11 func assert(cond bool, msg string) {
12 if !cond {
13 print("assertion fail: ", msg, "\n")
14 panic(1)
18 const (
19 x int = iota
20 y = iota
21 z = 1 << iota
22 f float32 = 2 * iota
23 g float32 = 4.5 * float32(iota)
26 const (
27 X = 0
32 const (
33 A = 1 << iota
37 E = iota * iota
42 const (
43 a = 1
44 b = iota << a
45 c = iota << b
49 const (
50 i = (a << iota) + (b * iota)
56 const (
57 m = iota == 0
61 const (
62 p = float32(iota)
67 const (
68 s = string(iota + 'a')
72 const (
73 abit, amask = 1 << iota, 1<<iota - 1
74 bbit, bmask = 1 << iota, 1<<iota - 1
75 cbit, cmask = 1 << iota, 1<<iota - 1
78 func main() {
79 assert(x == 0, "x")
80 assert(y == 1, "y")
81 assert(z == 4, "z")
82 assert(f == 6.0, "f")
83 assert(g == 18.0, "g")
85 assert(X == 0, "X")
86 assert(Y == 0, "Y")
87 assert(Z == 0, "Z")
89 assert(A == 1, "A")
90 assert(B == 2, "B")
91 assert(C == 4, "C")
92 assert(D == 8, "D")
93 assert(E == 16, "E")
94 assert(F == 25, "F")
96 assert(a == 1, "a")
97 assert(b == 2, "b")
98 assert(c == 8, "c")
99 assert(d == 12, "d")
101 assert(i == 1, "i")
102 assert(j == 4, "j")
103 assert(k == 8, "k")
104 assert(l == 14, "l")
106 assert(m, "m")
107 assert(!n, "n")
109 assert(p == 0.0, "p")
110 assert(q == 1.0, "q")
111 assert(r == 2.0, "r")
113 assert(s == "a", "s")
114 assert(t == "b", "t")
116 assert(abit == 1, "abit")
117 assert(amask == 0, "amask")
118 assert(bbit == 2, "bbit")
119 assert(bmask == 1, "bmask")
120 assert(cbit == 4, "cbit")
121 assert(cmask == 3, "cmask")