OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [iota.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $F.go && $L $F.$A && ./$A.out
2
 
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.
6
 
7
package main
8
 
9
func assert(cond bool, msg string) {
10
        if !cond {
11
                print("assertion fail: ", msg, "\n")
12
                panic(1)
13
        }
14
}
15
 
16
const (
17
        x int = iota
18
        y = iota
19
        z = 1 << iota
20
        f float32 = 2 * iota
21
        g float32 = 4.5 * float32(iota)
22
)
23
 
24
const (
25
        X = 0
26
        Y
27
        Z
28
)
29
 
30
const (
31
        A = 1 << iota
32
        B
33
        C
34
        D
35
        E = iota * iota
36
        F
37
        G
38
)
39
 
40
const (
41
        a = 1
42
        b = iota << a
43
        c = iota << b
44
        d
45
)
46
 
47
const (
48
        i = (a << iota) + (b * iota)
49
        j
50
        k
51
        l
52
)
53
 
54
const (
55
        m = iota == 0
56
        n
57
)
58
 
59
const (
60
        p = float32(iota)
61
        q
62
        r
63
)
64
 
65
const (
66
        s = string(iota + 'a')
67
        t
68
)
69
 
70
const (
71
        abit, amask = 1 << iota, 1<
72
        bbit, bmask = 1 << iota, 1<
73
        cbit, cmask = 1 << iota, 1<
74
)
75
 
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")
82
 
83
        assert(X == 0, "X")
84
        assert(Y == 0, "Y")
85
        assert(Z == 0, "Z")
86
 
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")
93
 
94
        assert(a == 1, "a")
95
        assert(b == 2, "b")
96
        assert(c == 8, "c")
97
        assert(d == 12, "d")
98
 
99
        assert(i == 1, "i")
100
        assert(j == 4, "j")
101
        assert(k == 8, "k")
102
        assert(l == 14, "l")
103
 
104
        assert(m, "m")
105
        assert(!n, "n")
106
 
107
        assert(p == 0.0, "p")
108
        assert(q == 1.0, "q")
109
        assert(r == 2.0, "r")
110
 
111
        assert(s == "a", "s")
112
        assert(t == "b", "t")
113
 
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")
120
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.