Brent Austin | ba3052e | 2015-04-21 16:08:23 -0700 | [diff] [blame] | 1 | // run |
| 2 | |
Dan Willemsen | 38f2dba | 2016-07-08 14:54:35 -0700 | [diff] [blame] | 3 | // Copyright 2011 The Go Authors. All rights reserved. |
Brent Austin | ba3052e | 2015-04-21 16:08:23 -0700 | [diff] [blame] | 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 various parsing cases that are a little |
Dan Willemsen | a322328 | 2018-02-27 19:41:43 -0800 | [diff] [blame] | 8 | // different now that send is a statement, not an expression. |
Brent Austin | ba3052e | 2015-04-21 16:08:23 -0700 | [diff] [blame] | 9 | |
| 10 | package main |
| 11 | |
| 12 | func main() { |
| 13 | chanchan() |
| 14 | sendprec() |
| 15 | } |
| 16 | |
| 17 | func chanchan() { |
| 18 | cc := make(chan chan int, 1) |
| 19 | c := make(chan int, 1) |
| 20 | cc <- c |
| 21 | select { |
| 22 | case <-cc <- 2: |
| 23 | default: |
| 24 | panic("nonblock") |
| 25 | } |
| 26 | if <-c != 2 { |
| 27 | panic("bad receive") |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | func sendprec() { |
| 32 | c := make(chan bool, 1) |
Dan Willemsen | d279748 | 2017-07-26 13:13:13 -0700 | [diff] [blame] | 33 | c <- false || true // not a syntax error: same as c <- (false || true) |
Brent Austin | ba3052e | 2015-04-21 16:08:23 -0700 | [diff] [blame] | 34 | if !<-c { |
| 35 | panic("sent false") |
| 36 | } |
| 37 | } |