Debian Codegraph @

gcc/testsuite/go.test/test/chan/select8.go

raw
1 // run
2
3 // Copyright 2019 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 break statements in a select.
8 // Gccgo had a bug in handling this.
9 // Test 1,2,3-case selects, so it covers both the general
10 // code path and the specialized optimizations for one-
11 // and two-case selects.
12
13 package main
14
15 var ch = make(chan int)
16
17 func main() {
18 go func() {
19 for {
20 ch <- 5
21 }
22 }()
23
24 select {
25 case <-ch:
26 break
27 panic("unreachable")
28 }
29
30 select {
31 default:
32 break
33 panic("unreachable")
34 }
35
36 select {
37 case <-ch:
38 break
39 panic("unreachable")
40 default:
41 break
42 panic("unreachable")
43 }
44
45 select {
46 case <-ch:
47 break
48 panic("unreachable")
49 case ch <- 10:
50 panic("unreachable")
51 default:
52 break
53 panic("unreachable")
54 }
55 }