mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
add Close() and Closed() to ChanValue
R=r DELTA=60 (56 added, 3 deleted, 1 changed) OCL=33868 CL=33872
This commit is contained in:
parent
06c2c89452
commit
653cef1ba0
5 changed files with 58 additions and 5 deletions
|
|
@ -726,6 +726,25 @@ func TestChan(t *testing.T) {
|
|||
t.Errorf("TrySend 6, recv %d", i);
|
||||
}
|
||||
}
|
||||
|
||||
// Close
|
||||
c <- 123;
|
||||
cv.Close();
|
||||
if cv.Closed() {
|
||||
t.Errorf("closed too soon - 1");
|
||||
}
|
||||
if i := cv.Recv().(*IntValue).Get(); i != 123 {
|
||||
t.Errorf("send 123 then close; Recv %d", i);
|
||||
}
|
||||
if cv.Closed() {
|
||||
t.Errorf("closed too soon - 2");
|
||||
}
|
||||
if i := cv.Recv().(*IntValue).Get(); i != 0 {
|
||||
t.Errorf("after close Recv %d", i);
|
||||
}
|
||||
if !cv.Closed() {
|
||||
t.Errorf("not closed");
|
||||
}
|
||||
}
|
||||
|
||||
// check creation of unbuffered channel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue