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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [blank.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
import _ "fmt"
10
 
11
var call string
12
 
13
type T struct {
14
        _, _, _ int
15
}
16
 
17
func (T) _() {
18
}
19
 
20
func (T) _() {
21
}
22
 
23
const (
24
        c0 = iota
25
        _
26
        _
27
        _
28
        c4
29
)
30
 
31
var ints = []string{
32
        "1",
33
        "2",
34
        "3",
35
}
36
 
37
func f() (int, int) {
38
        call += "f"
39
        return 1, 2
40
}
41
 
42
func g() (float64, float64) {
43
        call += "g"
44
        return 3, 4
45
}
46
 
47
func h(_ int, _ float64) {
48
}
49
 
50
func i() int {
51
        call += "i"
52
        return 23
53
}
54
 
55
var _ = i()
56
 
57
func main() {
58
        if call != "i" {
59
                panic("init did not run")
60
        }
61
        call = ""
62
        _, _ = f()
63
        a, _ := f()
64
        if a != 1 {
65
                panic(a)
66
        }
67
        b, _ := g()
68
        if b != 3 {
69
                panic(b)
70
        }
71
        _, a = f()
72
        if a != 2 {
73
                panic(a)
74
        }
75
        _, b = g()
76
        if b != 4 {
77
                panic(b)
78
        }
79
        _ = i()
80
        if call != "ffgfgi" {
81
                panic(call)
82
        }
83
        if c4 != 4 {
84
                panic(c4)
85
        }
86
 
87
        out := ""
88
        for _, s := range ints {
89
                out += s
90
        }
91
        if out != "123" {
92
                panic(out)
93
        }
94
 
95
        sum := 0
96
        for s := range ints {
97
                sum += s
98
        }
99
        if sum != 3 {
100
                panic(sum)
101
        }
102
 
103
        h(a, b)
104
 
105
        m()
106
}
107
 
108
type I interface {
109
        M(_ int, y int)
110
}
111
 
112
type TI struct{}
113
 
114
func (TI) M(x int, y int) {
115
        if x != y {
116
                println("invalid M call:", x, y)
117
                panic("bad M")
118
        }
119
}
120
 
121
var fp = func(_ int, y int) {}
122
 
123
func init() {
124
        fp = fp1
125
}
126
 
127
func fp1(x, y int) {
128
        if x != y {
129
                println("invalid fp1 call:", x, y)
130
                panic("bad fp1")
131
        }
132
}
133
 
134
 
135
func m() {
136
        var i I
137
 
138
        i = TI{}
139
        i.M(1, 1)
140
        i.M(2, 2)
141
 
142
        fp(1, 1)
143
        fp(2, 2)
144
}
145
 
146
// useless but legal
147
var _ int = 1
148
var _ = 2
149
var _, _ = 3, 4
150
 
151
const _ = 3
152
const _, _ = 4, 5
153
 
154
type _ int
155
 
156
func _() {
157
        panic("oops")
158
}
159
 
160
func ff() {
161
        var _ int = 1
162
}
163
 

powered by: WebSVN 2.1.0

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