1// run 2 3// Copyright 2010 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// Test case for https://golang.org/issue/692 8 9package main 10 11var fooCount = 0 12var barCount = 0 13var balCount = 0 14 15func foo() (int, int) { 16 fooCount++ 17 return 0, 0 18} 19 20func bar() (int, int) { 21 barCount++ 22 return 0, 0 23} 24 25func bal() (int, int) { 26 balCount++ 27 return 0, 0 28} 29 30var a, b = foo() // foo is called once 31var c, _ = bar() // bar is called twice 32var _, _ = bal() // bal is called twice 33 34func main() { 35 if fooCount != 1 { 36 panic("fooCount != 1") 37 } 38 if barCount != 1 { 39 panic("barCount != 1") 40 } 41 if balCount != 1 { 42 panic("balCount != 1") 43 } 44} 45