blob: 2f320def263d4012d84302e15be12ba4072907b9 [file] [log] [blame]
Rémy Oudompheng2ece2f52012-02-18 22:15:42 +01001// run
Robert Griesemera291e992010-03-25 10:01:51 -07002
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
Brad Fitzpatrick2ae77372015-07-10 17:17:11 -06007// Test case for https://golang.org/issue/692
Robert Griesemera291e992010-03-25 10:01:51 -07008
9package main
10
Robert Griesemera291e992010-03-25 10:01:51 -070011var fooCount = 0
12var barCount = 0
13var balCount = 0
14
15func foo() (int, int) {
16 fooCount++
Robert Griesemera291e992010-03-25 10:01:51 -070017 return 0, 0
18}
19
20func bar() (int, int) {
21 barCount++
Robert Griesemera291e992010-03-25 10:01:51 -070022 return 0, 0
23}
24
25func bal() (int, int) {
26 balCount++
Robert Griesemera291e992010-03-25 10:01:51 -070027 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 {
Rob Pikec93273c2010-03-25 14:27:24 -070036 panic("fooCount != 1")
Robert Griesemera291e992010-03-25 10:01:51 -070037 }
38 if barCount != 1 {
Rob Pikec93273c2010-03-25 14:27:24 -070039 panic("barCount != 1")
Robert Griesemera291e992010-03-25 10:01:51 -070040 }
41 if balCount != 1 {
Rob Pikec93273c2010-03-25 14:27:24 -070042 panic("balCount != 1")
Robert Griesemera291e992010-03-25 10:01:51 -070043 }
44}