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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$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
const (
10
        ci8  = -1 << 7
11
        ci16 = -1<<15 + 100
12
        ci32 = -1<<31 + 100000
13
        ci64 = -1<<63 + 10000000001
14
 
15
        cu8  = 1<<8 - 1
16
        cu16 = 1<<16 - 1234
17
        cu32 = 1<<32 - 1234567
18
        cu64 = 1<<64 - 1234567890123
19
 
20
        cf32 = 1e8 + 0.5
21
        cf64 = -1e8 + 0.5
22
)
23
 
24
var (
25
        i8  int8  = ci8
26
        i16 int16 = ci16
27
        i32 int32 = ci32
28
        i64 int64 = ci64
29
 
30
        u8  uint8  = cu8
31
        u16 uint16 = cu16
32
        u32 uint32 = cu32
33
        u64 uint64 = cu64
34
 
35
        //      f32 float32 = 1e8 + 0.5
36
        //      f64 float64 = -1e8 + 0.5
37
)
38
 
39
func chki8(i, v int8) {
40
        if i != v {
41
                println(i, "!=", v)
42
                panic("fail")
43
        }
44
}
45
func chki16(i, v int16) {
46
        if i != v {
47
                println(i, "!=", v)
48
                panic("fail")
49
        }
50
}
51
func chki32(i, v int32) {
52
        if i != v {
53
                println(i, "!=", v)
54
                panic("fail")
55
        }
56
}
57
func chki64(i, v int64) {
58
        if i != v {
59
                println(i, "!=", v)
60
                panic("fail")
61
        }
62
}
63
func chku8(i, v uint8) {
64
        if i != v {
65
                println(i, "!=", v)
66
                panic("fail")
67
        }
68
}
69
func chku16(i, v uint16) {
70
        if i != v {
71
                println(i, "!=", v)
72
                panic("fail")
73
        }
74
}
75
func chku32(i, v uint32) {
76
        if i != v {
77
                println(i, "!=", v)
78
                panic("fail")
79
        }
80
}
81
func chku64(i, v uint64) {
82
        if i != v {
83
                println(i, "!=", v)
84
                panic("fail")
85
        }
86
}
87
//func chkf32(f, v float32) { if f != v { println(f, "!=", v); panic("fail") } }
88
//func chkf64(f, v float64) { if f != v { println(f, "!=", v); panic("fail") } }
89
 
90
func main() {
91
        chki8(int8(i8), ci8&0xff-1<<8)
92
        chki8(int8(i16), ci16&0xff)
93
        chki8(int8(i32), ci32&0xff-1<<8)
94
        chki8(int8(i64), ci64&0xff)
95
        chki8(int8(u8), cu8&0xff-1<<8)
96
        chki8(int8(u16), cu16&0xff)
97
        chki8(int8(u32), cu32&0xff)
98
        chki8(int8(u64), cu64&0xff)
99
        //      chki8(int8(f32), 0)
100
        //      chki8(int8(f64), 0)
101
 
102
        chki16(int16(i8), ci8&0xffff-1<<16)
103
        chki16(int16(i16), ci16&0xffff-1<<16)
104
        chki16(int16(i32), ci32&0xffff-1<<16)
105
        chki16(int16(i64), ci64&0xffff-1<<16)
106
        chki16(int16(u8), cu8&0xffff)
107
        chki16(int16(u16), cu16&0xffff-1<<16)
108
        chki16(int16(u32), cu32&0xffff)
109
        chki16(int16(u64), cu64&0xffff-1<<16)
110
        //      chki16(int16(f32), 0)
111
        //      chki16(int16(f64), 0)
112
 
113
        chki32(int32(i8), ci8&0xffffffff-1<<32)
114
        chki32(int32(i16), ci16&0xffffffff-1<<32)
115
        chki32(int32(i32), ci32&0xffffffff-1<<32)
116
        chki32(int32(i64), ci64&0xffffffff)
117
        chki32(int32(u8), cu8&0xffffffff)
118
        chki32(int32(u16), cu16&0xffffffff)
119
        chki32(int32(u32), cu32&0xffffffff-1<<32)
120
        chki32(int32(u64), cu64&0xffffffff-1<<32)
121
        //      chki32(int32(f32), 0)
122
        //      chki32(int32(f64), 0)
123
 
124
        chki64(int64(i8), ci8&0xffffffffffffffff-1<<64)
125
        chki64(int64(i16), ci16&0xffffffffffffffff-1<<64)
126
        chki64(int64(i32), ci32&0xffffffffffffffff-1<<64)
127
        chki64(int64(i64), ci64&0xffffffffffffffff-1<<64)
128
        chki64(int64(u8), cu8&0xffffffffffffffff)
129
        chki64(int64(u16), cu16&0xffffffffffffffff)
130
        chki64(int64(u32), cu32&0xffffffffffffffff)
131
        chki64(int64(u64), cu64&0xffffffffffffffff-1<<64)
132
        //      chki64(int64(f32), 0)
133
        //      chki64(int64(f64), 0)
134
 
135
 
136
        chku8(uint8(i8), ci8&0xff)
137
        chku8(uint8(i16), ci16&0xff)
138
        chku8(uint8(i32), ci32&0xff)
139
        chku8(uint8(i64), ci64&0xff)
140
        chku8(uint8(u8), cu8&0xff)
141
        chku8(uint8(u16), cu16&0xff)
142
        chku8(uint8(u32), cu32&0xff)
143
        chku8(uint8(u64), cu64&0xff)
144
        //      chku8(uint8(f32), 0)
145
        //      chku8(uint8(f64), 0)
146
 
147
        chku16(uint16(i8), ci8&0xffff)
148
        chku16(uint16(i16), ci16&0xffff)
149
        chku16(uint16(i32), ci32&0xffff)
150
        chku16(uint16(i64), ci64&0xffff)
151
        chku16(uint16(u8), cu8&0xffff)
152
        chku16(uint16(u16), cu16&0xffff)
153
        chku16(uint16(u32), cu32&0xffff)
154
        chku16(uint16(u64), cu64&0xffff)
155
        //      chku16(uint16(f32), 0)
156
        //      chku16(uint16(f64), 0)
157
 
158
        chku32(uint32(i8), ci8&0xffffffff)
159
        chku32(uint32(i16), ci16&0xffffffff)
160
        chku32(uint32(i32), ci32&0xffffffff)
161
        chku32(uint32(i64), ci64&0xffffffff)
162
        chku32(uint32(u8), cu8&0xffffffff)
163
        chku32(uint32(u16), cu16&0xffffffff)
164
        chku32(uint32(u32), cu32&0xffffffff)
165
        chku32(uint32(u64), cu64&0xffffffff)
166
        //      chku32(uint32(f32), 0)
167
        //      chku32(uint32(f64), 0)
168
 
169
        chku64(uint64(i8), ci8&0xffffffffffffffff)
170
        chku64(uint64(i16), ci16&0xffffffffffffffff)
171
        chku64(uint64(i32), ci32&0xffffffffffffffff)
172
        chku64(uint64(i64), ci64&0xffffffffffffffff)
173
        chku64(uint64(u8), cu8&0xffffffffffffffff)
174
        chku64(uint64(u16), cu16&0xffffffffffffffff)
175
        chku64(uint64(u32), cu32&0xffffffffffffffff)
176
        chku64(uint64(u64), cu64&0xffffffffffffffff)
177
        //      chku64(uint64(f32), 0)
178
        //      chku64(uint64(f64), 0)
179
}

powered by: WebSVN 2.1.0

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