OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [chan/] [select7.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out
2
 
3
// Copyright 2011 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 select when discarding a value.
8
 
9
package main
10
 
11
import "runtime"
12
 
13
func recv1(c <-chan int) {
14
        <-c
15
}
16
 
17
func recv2(c <-chan int) {
18
        select {
19
        case <-c:
20
        }
21
}
22
 
23
func recv3(c <-chan int) {
24
        c2 := make(chan int)
25
        select {
26
        case <-c:
27
        case <-c2:
28
        }
29
}
30
 
31
func send1(recv func(<-chan int)) {
32
        c := make(chan int)
33
        go recv(c)
34
        runtime.Gosched()
35
        c <- 1
36
}
37
 
38
func send2(recv func(<-chan int)) {
39
        c := make(chan int)
40
        go recv(c)
41
        runtime.Gosched()
42
        select {
43
        case c <- 1:
44
        }
45
}
46
 
47
func send3(recv func(<-chan int)) {
48
        c := make(chan int)
49
        go recv(c)
50
        runtime.Gosched()
51
        c2 := make(chan int)
52
        select {
53
        case c <- 1:
54
        case c2 <- 1:
55
        }
56
}
57
 
58
func main() {
59
        send1(recv1)
60
        send2(recv1)
61
        send3(recv1)
62
        send1(recv2)
63
        send2(recv2)
64
        send3(recv2)
65
        send1(recv3)
66
        send2(recv3)
67
        send3(recv3)
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.