Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / go.test / test / iota.go
blob20b77c6cc05b6d83d2e1ff83c99cc49dc63ecfc9
1 // $G $F.go && $L $F.$A && ./$A.out
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 package main
9 func assert(cond bool, msg string) {
10 if !cond {
11 print("assertion fail: ", msg, "\n")
12 panic(1)
16 const (
17 x int = iota
18 y = iota
19 z = 1 << iota
20 f float = 2 * iota
21 g float = 4.5 * float(iota)
24 const (
25 X = 0
30 const (
31 A = 1 << iota
35 E = iota * iota
40 const (
41 a = 1
42 b = iota << a
43 c = iota << b
47 const (
48 i = (a << iota) + (b * iota)
54 const (
55 m = iota == 0
59 const (
60 p = float(iota)
65 const (
66 s = string(iota + 'a')
70 const (
71 abit, amask = 1 << iota, 1 << iota - 1
72 bbit, bmask = 1 << iota, 1 << iota - 1
73 cbit, cmask = 1 << iota, 1 << iota - 1
76 func main() {
77 assert(x == 0, "x")
78 assert(y == 1, "y")
79 assert(z == 4, "z")
80 assert(f == 6.0, "f")
81 assert(g == 18.0, "g")
83 assert(X == 0, "X")
84 assert(Y == 0, "Y")
85 assert(Z == 0, "Z")
87 assert(A == 1, "A")
88 assert(B == 2, "B")
89 assert(C == 4, "C")
90 assert(D == 8, "D")
91 assert(E == 16, "E")
92 assert(F == 25, "F")
94 assert(a == 1, "a")
95 assert(b == 2, "b")
96 assert(c == 8, "c")
97 assert(d == 12, "d")
99 assert(i == 1, "i")
100 assert(j == 4, "j")
101 assert(k == 8, "k")
102 assert(l == 14, "l")
104 assert(m, "m")
105 assert(!n, "n")
107 assert(p == 0.0, "p")
108 assert(q == 1.0, "q")
109 assert(r == 2.0, "r")
111 assert(s == "a", "s")
112 assert(t == "b", "t")
114 assert(abit == 1, "abit")
115 assert(amask == 0, "amask")
116 assert(bbit == 2, "bbit")
117 assert(bmask == 1, "bmask")
118 assert(cbit == 4, "cbit")
119 assert(cmask == 3, "cmask")