diff options
author | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
---|---|---|
committer | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
commit | 643df0593c630691fa6877cddeefdd4c3023d444 (patch) | |
tree | 1eb48ad31d05a9ce117bedc17115de96dffa2f0b /gcc/testsuite/go.test/test/closedchan.go | |
parent | 54f3f029d816c6d1626310649adfda740e203f7b (diff) | |
parent | d5d8f1ccc6d3972dc5cfc0949e85e0b1c9e24ee0 (diff) | |
download | gcc-transactional-memory.tar.gz |
* Merge from mainline rev 181122.transactional-memory
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/transactional-memory@181148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/go.test/test/closedchan.go')
-rw-r--r-- | gcc/testsuite/go.test/test/closedchan.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/go.test/test/closedchan.go b/gcc/testsuite/go.test/test/closedchan.go index 95314b3345e..c2bbec59d95 100644 --- a/gcc/testsuite/go.test/test/closedchan.go +++ b/gcc/testsuite/go.test/test/closedchan.go @@ -11,6 +11,10 @@ package main +import "os" + +var failed bool + type Chan interface { Send(int) Nbsend(int) bool @@ -225,19 +229,23 @@ func test1(c Chan) { // recv a close signal (a zero value) if x := c.Recv(); x != 0 { println("test1: recv on closed:", x, c.Impl()) + failed = true } if x, ok := c.Recv2(); x != 0 || ok { println("test1: recv2 on closed:", x, ok, c.Impl()) + failed = true } // should work with select: received a value without blocking, so selected == true. x, selected := c.Nbrecv() if x != 0 || !selected { println("test1: recv on closed nb:", x, selected, c.Impl()) + failed = true } x, ok, selected := c.Nbrecv2() if x != 0 || ok || !selected { println("test1: recv2 on closed nb:", x, ok, selected, c.Impl()) + failed = true } } @@ -247,12 +255,14 @@ func test1(c Chan) { // the value should have been discarded. if x := c.Recv(); x != 0 { println("test1: recv on closed got non-zero after send on closed:", x, c.Impl()) + failed = true } // similarly Send. shouldPanic(func() { c.Send(2) }) if x := c.Recv(); x != 0 { println("test1: recv on closed got non-zero after send on closed:", x, c.Impl()) + failed = true } } @@ -260,6 +270,7 @@ func testasync1(c Chan) { // should be able to get the last value via Recv if x := c.Recv(); x != 1 { println("testasync1: Recv did not get 1:", x, c.Impl()) + failed = true } test1(c) @@ -269,6 +280,7 @@ func testasync2(c Chan) { // should be able to get the last value via Recv2 if x, ok := c.Recv2(); x != 1 || !ok { println("testasync1: Recv did not get 1, true:", x, ok, c.Impl()) + failed = true } test1(c) @@ -278,6 +290,7 @@ func testasync3(c Chan) { // should be able to get the last value via Nbrecv if x, selected := c.Nbrecv(); x != 1 || !selected { println("testasync2: Nbrecv did not get 1, true:", x, selected, c.Impl()) + failed = true } test1(c) @@ -287,6 +300,7 @@ func testasync4(c Chan) { // should be able to get the last value via Nbrecv2 if x, ok, selected := c.Nbrecv2(); x != 1 || !ok || !selected { println("testasync2: Nbrecv did not get 1, true, true:", x, ok, selected, c.Impl()) + failed = true } test1(c) } @@ -327,4 +341,19 @@ func main() { testclosed(mk(closedasync())) } } + + var ch chan int + shouldPanic(func() { + close(ch) + }) + + ch = make(chan int) + close(ch) + shouldPanic(func() { + close(ch) + }) + + if failed { + os.Exit(1) + } } |