2012-02-16 21:48:57 -07:00
|
|
|
// run
|
2011-02-01 06:29:21 -07:00
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-02-01 06:29:21 -07: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-14 19:24:47 -06:00
|
|
|
// different now that send is a statement, not an expression.
|
2011-02-01 06:29:21 -07: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 15:53:12 -06:00
|
|
|
c <- false || true // not a syntax error: same as c <- (false || true)
|
2011-02-01 06:29:21 -07:00
|
|
|
if !<-c {
|
|
|
|
panic("sent false")
|
|
|
|
}
|
|
|
|
}
|