blob: d296a55cda1fb5429193c696ca76ef40d1f2e796 [file] [log] [blame]
Brent Austinba3052e2015-04-21 16:08:23 -07001// run
2
Dan Willemsen38f2dba2016-07-08 14:54:35 -07003// Copyright 2011 The Go Authors. All rights reserved.
Brent Austinba3052e2015-04-21 16:08:23 -07004// 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 Willemsena3223282018-02-27 19:41:43 -08008// different now that send is a statement, not an expression.
Brent Austinba3052e2015-04-21 16:08:23 -07009
10package main
11
12func main() {
13 chanchan()
14 sendprec()
15}
16
17func 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
31func sendprec() {
32 c := make(chan bool, 1)
Dan Willemsend2797482017-07-26 13:13:13 -070033 c <- false || true // not a syntax error: same as c <- (false || true)
Brent Austinba3052e2015-04-21 16:08:23 -070034 if !<-c {
35 panic("sent false")
36 }
37}