github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/bug264.go (about) 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 http://code.google.com/p/go/issues/detail?id=692 8 9 package main 10 11 var fooCount = 0 12 var barCount = 0 13 var balCount = 0 14 15 func foo() (int, int) { 16 fooCount++ 17 return 0, 0 18 } 19 20 func bar() (int, int) { 21 barCount++ 22 return 0, 0 23 } 24 25 func bal() (int, int) { 26 balCount++ 27 return 0, 0 28 } 29 30 var a, b = foo() // foo is called once 31 var c, _ = bar() // bar is called twice 32 var _, _ = bal() // bal is called twice 33 34 func 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 }