2009-09-09 06:16:19 +00:00
|
|
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2009-09-09 23:59:41 +00:00
|
|
|
import _ "fmt"
|
|
|
|
|
2009-09-09 06:16:19 +00:00
|
|
|
var call string
|
|
|
|
|
|
|
|
type T struct {
|
2010-09-04 00:36:13 +00:00
|
|
|
_, _, _ int
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 23:59:41 +00:00
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
2009-09-09 06:16:19 +00:00
|
|
|
const (
|
2010-09-04 00:36:13 +00:00
|
|
|
c0 = iota
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
c4
|
2009-09-09 06:16:19 +00:00
|
|
|
)
|
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
var ints = []string{
|
2009-09-09 06:16:19 +00:00
|
|
|
"1",
|
|
|
|
"2",
|
2009-12-10 03:27:08 +00:00
|
|
|
"3",
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func f() (int, int) {
|
2010-09-04 00:36:13 +00:00
|
|
|
call += "f"
|
2011-01-20 04:09:00 +00:00
|
|
|
return 1, 2
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
func g() (float64, float64) {
|
2010-09-04 00:36:13 +00:00
|
|
|
call += "g"
|
2011-01-20 04:09:00 +00:00
|
|
|
return 3, 4
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
func h(_ int, _ float64) {
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func i() int {
|
2010-09-04 00:36:13 +00:00
|
|
|
call += "i"
|
|
|
|
return 23
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
2010-09-04 00:36:13 +00:00
|
|
|
var _ = i()
|
2009-10-20 02:27:40 +00:00
|
|
|
|
2009-09-09 23:59:41 +00:00
|
|
|
func main() {
|
2011-01-20 04:09:00 +00:00
|
|
|
if call != "i" {
|
|
|
|
panic("init did not run")
|
|
|
|
}
|
2010-09-04 00:36:13 +00:00
|
|
|
call = ""
|
|
|
|
_, _ = f()
|
|
|
|
a, _ := f()
|
2011-01-20 04:09:00 +00:00
|
|
|
if a != 1 {
|
|
|
|
panic(a)
|
|
|
|
}
|
2010-09-04 00:36:13 +00:00
|
|
|
b, _ := g()
|
2011-01-20 04:09:00 +00:00
|
|
|
if b != 3 {
|
|
|
|
panic(b)
|
|
|
|
}
|
2010-09-04 00:36:13 +00:00
|
|
|
_, a = f()
|
2011-01-20 04:09:00 +00:00
|
|
|
if a != 2 {
|
|
|
|
panic(a)
|
|
|
|
}
|
2010-09-04 00:36:13 +00:00
|
|
|
_, b = g()
|
2011-01-20 04:09:00 +00:00
|
|
|
if b != 4 {
|
|
|
|
panic(b)
|
|
|
|
}
|
2010-09-04 00:36:13 +00:00
|
|
|
_ = i()
|
2011-01-20 04:09:00 +00:00
|
|
|
if call != "ffgfgi" {
|
|
|
|
panic(call)
|
|
|
|
}
|
|
|
|
if c4 != 4 {
|
|
|
|
panic(c4)
|
|
|
|
}
|
2009-09-09 06:16:19 +00:00
|
|
|
|
2010-09-04 00:36:13 +00:00
|
|
|
out := ""
|
2009-09-09 06:16:19 +00:00
|
|
|
for _, s := range ints {
|
2010-09-04 00:36:13 +00:00
|
|
|
out += s
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
2011-01-20 04:09:00 +00:00
|
|
|
if out != "123" {
|
|
|
|
panic(out)
|
|
|
|
}
|
2009-09-09 06:16:19 +00:00
|
|
|
|
2010-09-04 00:36:13 +00:00
|
|
|
sum := 0
|
2010-12-09 05:36:56 +00:00
|
|
|
for s := range ints {
|
2010-09-04 00:36:13 +00:00
|
|
|
sum += s
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
2011-01-20 04:09:00 +00:00
|
|
|
if sum != 3 {
|
|
|
|
panic(sum)
|
|
|
|
}
|
2009-09-09 06:16:19 +00:00
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
h(a, b)
|
2011-11-28 21:40:39 +00:00
|
|
|
|
|
|
|
m()
|
|
|
|
}
|
|
|
|
|
|
|
|
type I interface {
|
|
|
|
M(_ int, y int)
|
|
|
|
}
|
|
|
|
|
|
|
|
type TI struct{}
|
|
|
|
|
|
|
|
func (TI) M(x int, y int) {
|
|
|
|
if x != y {
|
|
|
|
println("invalid M call:", x, y)
|
|
|
|
panic("bad M")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func m() {
|
|
|
|
var i I
|
|
|
|
|
|
|
|
i = TI{}
|
|
|
|
i.M(1, 1)
|
|
|
|
i.M(2, 2)
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// useless but legal
|
2010-09-04 00:36:13 +00:00
|
|
|
var _ int = 1
|
|
|
|
var _ = 2
|
|
|
|
var _, _ = 3, 4
|
2011-01-20 04:09:00 +00:00
|
|
|
|
2010-09-04 00:36:13 +00:00
|
|
|
const _ = 3
|
|
|
|
const _, _ = 4, 5
|
2011-01-20 04:09:00 +00:00
|
|
|
|
2010-09-04 00:36:13 +00:00
|
|
|
type _ int
|
2011-01-20 04:09:00 +00:00
|
|
|
|
2009-09-09 06:16:19 +00:00
|
|
|
func _() {
|
|
|
|
panic("oops")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ff() {
|
2010-09-04 00:36:13 +00:00
|
|
|
var _ int = 1
|
2009-09-09 06:16:19 +00:00
|
|
|
}
|
2011-11-28 21:40:39 +00:00
|
|
|
|