diff options
| author | Russ Cox <rsc@golang.org> | 2011-01-31 18:36:28 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-01-31 18:36:28 -0500 |
| commit | f4e76d83091b43e88bb2a832c3b6424c3cc17e1d (patch) | |
| tree | 6527360b647fd1fabce1dbc839ba03e24c308163 /src/pkg/path | |
| parent | fc52d7029fcd667557230d4b4b6443886e261ef9 (diff) | |
| download | go-f4e76d83091b43e88bb2a832c3b6424c3cc17e1d.tar.xz | |
replace non-blocking send, receive syntax with select
R=golang-dev, nigeltao, niemeyer, r
CC=golang-dev
https://golang.org/cl/4079053
Diffstat (limited to 'src/pkg/path')
| -rw-r--r-- | src/pkg/path/path_test.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pkg/path/path_test.go b/src/pkg/path/path_test.go index 6b4be07a95..ab0b48ad6a 100644 --- a/src/pkg/path/path_test.go +++ b/src/pkg/path/path_test.go @@ -256,8 +256,11 @@ func TestWalk(t *testing.T) { // 2) handle errors, expect none errors := make(chan os.Error, 64) Walk(tree.name, v, errors) - if err, ok := <-errors; ok { + select { + case err := <-errors: t.Errorf("no error expected, found: %s", err) + default: + // ok } checkMarks(t) @@ -276,14 +279,21 @@ func TestWalk(t *testing.T) { errors = make(chan os.Error, 64) os.Chmod(Join(tree.name, tree.entries[1].name), 0) Walk(tree.name, v, errors) + Loop: for i := 1; i <= 2; i++ { - if _, ok := <-errors; !ok { + select { + case <-errors: + // ok + default: t.Errorf("%d. error expected, none found", i) - break + break Loop } } - if err, ok := <-errors; ok { + select { + case err := <-errors: t.Errorf("only two errors expected, found 3rd: %v", err) + default: + // ok } // the inaccessible subtrees were marked manually checkMarks(t) |
