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