Commit 26a85211 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder Committed by Brad Fitzpatrick

test: gofmt chan/*.go

These are functional tests, so it is safe to gofmt them.

Change-Id: I3067279c1d49809ac6a62054448ab8a6c3de9bda
Reviewed-on: https://go-review.googlesource.com/43623Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a9bf3b2e
...@@ -54,4 +54,3 @@ func main() { ...@@ -54,4 +54,3 @@ func main() {
AsynchFifo() AsynchFifo()
SynchFifo() SynchFifo()
} }
...@@ -28,19 +28,19 @@ func main() { ...@@ -28,19 +28,19 @@ func main() {
<-n // ERROR "receive from non-chan" <-n // ERROR "receive from non-chan"
n <- 2 // ERROR "send to non-chan" n <- 2 // ERROR "send to non-chan"
c <- 0 // ok c <- 0 // ok
<-c // ok <-c // ok
x, ok := <-c // ok x, ok := <-c // ok
_, _ = x, ok _, _ = x, ok
cr <- 0 // ERROR "send" cr <- 0 // ERROR "send"
<-cr // ok <-cr // ok
x, ok = <-cr // ok x, ok = <-cr // ok
_, _ = x, ok _, _ = x, ok
cs <- 0 // ok cs <- 0 // ok
<-cs // ERROR "receive" <-cs // ERROR "receive"
x, ok = <-cs // ERROR "receive" x, ok = <-cs // ERROR "receive"
_, _ = x, ok _, _ = x, ok
select { select {
...@@ -57,14 +57,14 @@ func main() { ...@@ -57,14 +57,14 @@ func main() {
_ = x _ = x
} }
for _ = range cs {// ERROR "receive" for _ = range cs { // ERROR "receive"
} }
for range cs {// ERROR "receive" for range cs { // ERROR "receive"
} }
close(c) close(c)
close(cs) close(cs)
close(cr) // ERROR "receive" close(cr) // ERROR "receive"
close(n) // ERROR "invalid operation.*non-chan type" close(n) // ERROR "invalid operation.*non-chan type"
} }
This diff is collapsed.
This diff is collapsed.
...@@ -14,12 +14,10 @@ import "time" ...@@ -14,12 +14,10 @@ import "time"
const always = "function did not" const always = "function did not"
const never = "function did" const never = "function did"
func unreachable() { func unreachable() {
panic("control flow shouldn't reach here") panic("control flow shouldn't reach here")
} }
// Calls f and verifies that f always/never panics depending on signal. // Calls f and verifies that f always/never panics depending on signal.
func testPanic(signal string, f func()) { func testPanic(signal string, f func()) {
defer func() { defer func() {
...@@ -34,7 +32,6 @@ func testPanic(signal string, f func()) { ...@@ -34,7 +32,6 @@ func testPanic(signal string, f func()) {
f() f()
} }
// Calls f and empirically verifies that f always/never blocks depending on signal. // Calls f and empirically verifies that f always/never blocks depending on signal.
func testBlock(signal string, f func()) { func testBlock(signal string, f func()) {
c := make(chan string) c := make(chan string)
...@@ -51,7 +48,6 @@ func testBlock(signal string, f func()) { ...@@ -51,7 +48,6 @@ func testBlock(signal string, f func()) {
} }
} }
func main() { func main() {
const async = 1 // asynchronous channels const async = 1 // asynchronous channels
var nilch chan int var nilch chan int
...@@ -114,8 +110,7 @@ func main() { ...@@ -114,8 +110,7 @@ func main() {
// empty selects always block // empty selects always block
testBlock(always, func() { testBlock(always, func() {
select { select {}
}
}) })
// selects with only nil channels always block // selects with only nil channels always block
......
...@@ -30,7 +30,7 @@ func chanchan() { ...@@ -30,7 +30,7 @@ func chanchan() {
func sendprec() { func sendprec() {
c := make(chan bool, 1) c := make(chan bool, 1)
c <- false || true // not a syntax error: same as c <- (false || true) c <- false || true // not a syntax error: same as c <- (false || true)
if !<-c { if !<-c {
panic("sent false") panic("sent false")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment