2012-02-17 04:48:57 +00:00
|
|
|
// run
|
2011-02-01 13:29:21 +00:00
|
|
|
|
2016-04-10 21:32:26 +00:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-02-01 13:29:21 +00:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Test various parsing cases that are a little
|
2017-09-15 01:24:47 +00:00
|
|
|
// different now that send is a statement, not an expression.
|
2011-02-01 13:29:21 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
chanchan()
|
|
|
|
sendprec()
|
|
|
|
}
|
|
|
|
|
|
|
|
func chanchan() {
|
|
|
|
cc := make(chan chan int, 1)
|
|
|
|
c := make(chan int, 1)
|
|
|
|
cc <- c
|
|
|
|
select {
|
|
|
|
case <-cc <- 2:
|
|
|
|
default:
|
|
|
|
panic("nonblock")
|
|
|
|
}
|
|
|
|
if <-c != 2 {
|
|
|
|
panic("bad receive")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func sendprec() {
|
|
|
|
c := make(chan bool, 1)
|
2017-05-18 21:53:12 +00:00
|
|
|
c <- false || true // not a syntax error: same as c <- (false || true)
|
2011-02-01 13:29:21 +00:00
|
|
|
if !<-c {
|
|
|
|
panic("sent false")
|
|
|
|
}
|
|
|
|
}
|