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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [sliceslice.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
var bx []byte
10
var by []byte
11
var fx []float64
12
var fy []float64
13
var lb, hb int
14
var t int
15
 
16
func main() {
17
 
18
        // width 1 (byte)
19
        lb = 0
20
        hb = 10
21
        by = bx[lb:hb]
22
        tstb()
23
        by = bx[lb:10]
24
        tstb()
25
        by = bx[lb:]
26
        tstb()
27
        by = bx[:hb]
28
        tstb()
29
        by = bx[0:hb]
30
        tstb()
31
        by = bx[0:10]
32
        tstb()
33
        by = bx[0:]
34
        tstb()
35
        by = bx[:10]
36
        tstb()
37
        by = bx[:]
38
        tstb()
39
 
40
        lb = 2
41
        hb = 10
42
        by = bx[lb:hb]
43
        tstb()
44
        by = bx[lb:10]
45
        tstb()
46
        by = bx[lb:]
47
        tstb()
48
        by = bx[2:hb]
49
        tstb()
50
        by = bx[2:10]
51
        tstb()
52
        by = bx[2:]
53
        tstb()
54
 
55
        lb = 0
56
        hb = 8
57
        by = bx[lb:hb]
58
        tstb()
59
        by = bx[lb:8]
60
        tstb()
61
        by = bx[0:hb]
62
        tstb()
63
        by = bx[0:8]
64
        tstb()
65
        by = bx[:8]
66
        tstb()
67
        by = bx[:hb]
68
        tstb()
69
 
70
        lb = 2
71
        hb = 8
72
        by = bx[lb:hb]
73
        tstb()
74
        by = bx[lb:8]
75
        tstb()
76
        by = bx[2:hb]
77
        tstb()
78
        by = bx[2:8]
79
        tstb()
80
 
81
        // width 4 (float64)
82
        lb = 0
83
        hb = 10
84
        fy = fx[lb:hb]
85
        tstf()
86
        fy = fx[lb:10]
87
        tstf()
88
        fy = fx[lb:]
89
        tstf()
90
        fy = fx[:hb]
91
        tstf()
92
        fy = fx[0:hb]
93
        tstf()
94
        fy = fx[0:10]
95
        tstf()
96
        fy = fx[0:]
97
        tstf()
98
        fy = fx[:10]
99
        tstf()
100
        fy = fx[:]
101
        tstf()
102
 
103
        lb = 2
104
        hb = 10
105
        fy = fx[lb:hb]
106
        tstf()
107
        fy = fx[lb:10]
108
        tstf()
109
        fy = fx[lb:]
110
        tstf()
111
        fy = fx[2:hb]
112
        tstf()
113
        fy = fx[2:10]
114
        tstf()
115
        fy = fx[2:]
116
        tstf()
117
 
118
        lb = 0
119
        hb = 8
120
        fy = fx[lb:hb]
121
        tstf()
122
        fy = fx[lb:8]
123
        tstf()
124
        fy = fx[:hb]
125
        tstf()
126
        fy = fx[0:hb]
127
        tstf()
128
        fy = fx[0:8]
129
        tstf()
130
        fy = fx[:8]
131
        tstf()
132
 
133
        lb = 2
134
        hb = 8
135
        fy = fx[lb:hb]
136
        tstf()
137
        fy = fx[lb:8]
138
        tstf()
139
        fy = fx[2:hb]
140
        tstf()
141
        fy = fx[2:8]
142
        tstf()
143
}
144
 
145
func tstb() {
146
        t++
147
        if len(by) != hb-lb {
148
                println("t=", t, "lb=", lb, "hb=", hb,
149
                        "len=", len(by), "hb-lb=", hb-lb)
150
                panic("fail")
151
        }
152
        if cap(by) != len(bx)-lb {
153
                println("t=", t, "lb=", lb, "hb=", hb,
154
                        "cap=", cap(by), "len(bx)-lb=", len(bx)-lb)
155
                panic("fail")
156
        }
157
        for i := lb; i < hb; i++ {
158
                if bx[i] != by[i-lb] {
159
                        println("t=", t, "lb=", lb, "hb=", hb,
160
                                "bx[", i, "]=", bx[i],
161
                                "by[", i-lb, "]=", by[i-lb])
162
                        panic("fail")
163
                }
164
        }
165
        by = nil
166
}
167
 
168
func tstf() {
169
        t++
170
        if len(fy) != hb-lb {
171
                println("t=", t, "lb=", lb, "hb=", hb,
172
                        "len=", len(fy), "hb-lb=", hb-lb)
173
                panic("fail")
174
        }
175
        if cap(fy) != len(fx)-lb {
176
                println("t=", t, "lb=", lb, "hb=", hb,
177
                        "cap=", cap(fy), "len(fx)-lb=", len(fx)-lb)
178
                panic("fail")
179
        }
180
        for i := lb; i < hb; i++ {
181
                if fx[i] != fy[i-lb] {
182
                        println("t=", t, "lb=", lb, "hb=", hb,
183
                                "fx[", i, "]=", fx[i],
184
                                "fy[", i-lb, "]=", fy[i-lb])
185
                        panic("fail")
186
                }
187
        }
188
        fy = nil
189
}
190
 
191
func init() {
192
        bx = make([]byte, 10)
193
        for i := 0; i < len(bx); i++ {
194
                bx[i] = byte(i + 20)
195
        }
196
        by = nil
197
 
198
        fx = make([]float64, 10)
199
        for i := 0; i < len(fx); i++ {
200
                fx[i] = float64(i + 20)
201
        }
202
        fy = nil
203
}

powered by: WebSVN 2.1.0

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