Source file test/chan/sendstmt.go
1 // run 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 various parsing cases that are a little 8 // different now that send is a statement, not an expression. 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) 33 c <- false || true // not a syntax error: same as c <- (false || true) 34 if !<-c { 35 panic("sent false") 36 } 37 } 38