aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/go.go-torture/execute/select-1.go
blob: 8fc6963be3556725b4a88e3ce90c6c729c8774d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

func main() {
  ch1 := make(chan int);
  ch2 := make(chan int);
  go func (ch1, ch2 chan int) { ch1 <- 1; ch2 <- 2; } (ch1, ch2);
  count := 0;
  var v int;
  for count != 2 {
      select
	{
	case v := <- ch1:
	  if v != 1 {
	    panic(0)
	  }
	  count++

	case v = <- ch2:
	  if v != 2 {
	    panic(1)
	  }
	  count++
	}
    }
  if v != 2 {
    panic(2)
  }
}