Commit fbe7ba5b authored by Rob Pike's avatar Rob Pike

strengthen test by checking values

SVN=127601
parent f6c13bb2
...@@ -14,23 +14,23 @@ func pause() { ...@@ -14,23 +14,23 @@ func pause() {
} }
func i32receiver(c *chan int32) { func i32receiver(c *chan int32) {
<-c if <-c != 123 { panic "i32 value" }
} }
func i32sender(c *chan int32) { func i32sender(c *chan int32) {
c -< 1 c -< 234
} }
func i64receiver(c *chan int64) { func i64receiver(c *chan int64) {
<-c if <-c != 123456 { panic "i64 value" }
} }
func i64sender(c *chan int64) { func i64sender(c *chan int64) {
c -< 1 c -< 234567
} }
func breceiver(c *chan bool) { func breceiver(c *chan bool) {
<-c if ! <-c { panic "b value" }
} }
func bsender(c *chan bool) { func bsender(c *chan bool) {
...@@ -38,11 +38,11 @@ func bsender(c *chan bool) { ...@@ -38,11 +38,11 @@ func bsender(c *chan bool) {
} }
func sreceiver(c *chan string) { func sreceiver(c *chan string) {
<-c if <-c != "hello" { panic "s value" }
} }
func ssender(c *chan string) { func ssender(c *chan string) {
c -< "hi" c -< "hello again"
} }
func main() { func main() {
...@@ -71,21 +71,23 @@ func main() { ...@@ -71,21 +71,23 @@ func main() {
go i32receiver(c32); go i32receiver(c32);
pause(); pause();
ok = c32 -< 1; ok = c32 -< 123;
if !ok { panic "i32receiver" } if !ok { panic "i32receiver" }
go i32sender(c32); go i32sender(c32);
pause(); pause();
i32, ok = <-c32; i32, ok = <-c32;
if !ok { panic "i32sender" } if !ok { panic "i32sender" }
if i32 != 234 { panic "i32sender value" }
go i64receiver(c64); go i64receiver(c64);
pause(); pause();
ok = c64 -< 1; ok = c64 -< 123456;
if !ok { panic "i64receiver" } if !ok { panic "i64receiver" }
go i64sender(c64); go i64sender(c64);
pause(); pause();
i64, ok = <-c64; i64, ok = <-c64;
if !ok { panic "i64sender" } if !ok { panic "i64sender" }
if i64 != 234567 { panic "i64sender value" }
go breceiver(cb); go breceiver(cb);
pause(); pause();
...@@ -95,13 +97,16 @@ func main() { ...@@ -95,13 +97,16 @@ func main() {
pause(); pause();
b, ok = <-cb; b, ok = <-cb;
if !ok { panic "bsender" } if !ok { panic "bsender" }
if !b{ panic "bsender value" }
go sreceiver(cs); go sreceiver(cs);
pause(); pause();
ok = cs -< "hi"; ok = cs -< "hello";
if !ok { panic "sreceiver" } if !ok { panic "sreceiver" }
go ssender(cs); go ssender(cs);
pause(); pause();
s, ok = <-cs; s, ok = <-cs;
if !ok { panic "ssender" } if !ok { panic "ssender" }
if s != "hello again" { panic "ssender value" }
print "PASS\n"
} }
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