2009-09-09 00:16:19 -06: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 17:59:41 -06:00
|
|
|
import _ "fmt"
|
|
|
|
|
2009-09-09 00:16:19 -06:00
|
|
|
var call string
|
|
|
|
|
|
|
|
type T struct {
|
2010-09-03 18:36:13 -06:00
|
|
|
_, _, _ int
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
|
2009-09-09 17:59:41 -06:00
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
2009-09-09 00:16:19 -06:00
|
|
|
const (
|
2010-09-03 18:36:13 -06:00
|
|
|
c0 = iota
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
c4
|
2009-09-09 00:16:19 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var ints = []string {
|
|
|
|
"1",
|
|
|
|
"2",
|
2009-12-09 20:27:08 -07:00
|
|
|
"3",
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func f() (int, int) {
|
2010-09-03 18:36:13 -06:00
|
|
|
call += "f"
|
2009-09-09 00:16:19 -06:00
|
|
|
return 1,2
|
|
|
|
}
|
|
|
|
|
|
|
|
func g() (float, float) {
|
2010-09-03 18:36:13 -06:00
|
|
|
call += "g"
|
2009-09-09 00:16:19 -06:00
|
|
|
return 3,4
|
|
|
|
}
|
|
|
|
|
|
|
|
func h(_ int, _ float) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func i() int {
|
2010-09-03 18:36:13 -06:00
|
|
|
call += "i"
|
|
|
|
return 23
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
|
2010-09-03 18:36:13 -06:00
|
|
|
var _ = i()
|
2009-10-19 20:27:40 -06:00
|
|
|
|
2009-09-09 17:59:41 -06:00
|
|
|
func main() {
|
2009-10-19 20:27:40 -06:00
|
|
|
if call != "i" {panic("init did not run")}
|
2010-09-03 18:36:13 -06:00
|
|
|
call = ""
|
|
|
|
_, _ = f()
|
|
|
|
a, _ := f()
|
2009-09-09 00:16:19 -06:00
|
|
|
if a != 1 {panic(a)}
|
2010-09-03 18:36:13 -06:00
|
|
|
b, _ := g()
|
2009-09-09 00:16:19 -06:00
|
|
|
if b != 3 {panic(b)}
|
2010-09-03 18:36:13 -06:00
|
|
|
_, a = f()
|
2009-09-09 00:16:19 -06:00
|
|
|
if a != 2 {panic(a)}
|
2010-09-03 18:36:13 -06:00
|
|
|
_, b = g()
|
2009-09-09 00:16:19 -06:00
|
|
|
if b != 4 {panic(b)}
|
2010-09-03 18:36:13 -06:00
|
|
|
_ = i()
|
2009-09-09 00:16:19 -06:00
|
|
|
if call != "ffgfgi" {panic(call)}
|
|
|
|
if c4 != 4 {panic(c4)}
|
|
|
|
|
2010-09-03 18:36:13 -06:00
|
|
|
out := ""
|
2009-09-09 00:16:19 -06:00
|
|
|
for _, s := range ints {
|
2010-09-03 18:36:13 -06:00
|
|
|
out += s
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
if out != "123" {panic(out)}
|
|
|
|
|
2010-09-03 18:36:13 -06:00
|
|
|
sum := 0
|
2010-12-08 22:36:56 -07:00
|
|
|
for s := range ints {
|
2010-09-03 18:36:13 -06:00
|
|
|
sum += s
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
if sum != 3 {panic(sum)}
|
|
|
|
|
2010-09-03 18:36:13 -06:00
|
|
|
h(a,b)
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// useless but legal
|
2010-09-03 18:36:13 -06:00
|
|
|
var _ int = 1
|
|
|
|
var _ = 2
|
|
|
|
var _, _ = 3, 4
|
|
|
|
const _ = 3
|
|
|
|
const _, _ = 4, 5
|
|
|
|
type _ int
|
2009-09-09 00:16:19 -06:00
|
|
|
func _() {
|
|
|
|
panic("oops")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ff() {
|
2010-09-03 18:36:13 -06:00
|
|
|
var _ int = 1
|
2009-09-09 00:16:19 -06:00
|
|
|
}
|