summaryrefslogtreecommitdiff
path: root/libgo/go/rpc/jsonrpc/all_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/rpc/jsonrpc/all_test.go')
-rw-r--r--libgo/go/rpc/jsonrpc/all_test.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/libgo/go/rpc/jsonrpc/all_test.go b/libgo/go/rpc/jsonrpc/all_test.go
index 99253baf3cb..1451a0fed8a 100644
--- a/libgo/go/rpc/jsonrpc/all_test.go
+++ b/libgo/go/rpc/jsonrpc/all_test.go
@@ -5,11 +5,11 @@
package jsonrpc
import (
+ "errors"
"fmt"
"io"
"json"
"net"
- "os"
"rpc"
"testing"
)
@@ -24,25 +24,25 @@ type Reply struct {
type Arith int
-func (t *Arith) Add(args *Args, reply *Reply) os.Error {
+func (t *Arith) Add(args *Args, reply *Reply) error {
reply.C = args.A + args.B
return nil
}
-func (t *Arith) Mul(args *Args, reply *Reply) os.Error {
+func (t *Arith) Mul(args *Args, reply *Reply) error {
reply.C = args.A * args.B
return nil
}
-func (t *Arith) Div(args *Args, reply *Reply) os.Error {
+func (t *Arith) Div(args *Args, reply *Reply) error {
if args.B == 0 {
- return os.NewError("divide by zero")
+ return errors.New("divide by zero")
}
reply.C = args.A / args.B
return nil
}
-func (t *Arith) Error(args *Args, reply *Reply) os.Error {
+func (t *Arith) Error(args *Args, reply *Reply) error {
panic("ERROR")
}
@@ -105,7 +105,7 @@ func TestClient(t *testing.T) {
reply := new(Reply)
err := client.Call("Arith.Add", args, reply)
if err != nil {
- t.Errorf("Add: expected no error but got string %q", err.String())
+ t.Errorf("Add: expected no error but got string %q", err.Error())
}
if reply.C != args.A+args.B {
t.Errorf("Add: expected %d got %d", reply.C, args.A+args.B)
@@ -115,7 +115,7 @@ func TestClient(t *testing.T) {
reply = new(Reply)
err = client.Call("Arith.Mul", args, reply)
if err != nil {
- t.Errorf("Mul: expected no error but got string %q", err.String())
+ t.Errorf("Mul: expected no error but got string %q", err.Error())
}
if reply.C != args.A*args.B {
t.Errorf("Mul: expected %d got %d", reply.C, args.A*args.B)
@@ -130,7 +130,7 @@ func TestClient(t *testing.T) {
addCall = <-addCall.Done
if addCall.Error != nil {
- t.Errorf("Add: expected no error but got string %q", addCall.Error.String())
+ t.Errorf("Add: expected no error but got string %q", addCall.Error.Error())
}
if addReply.C != args.A+args.B {
t.Errorf("Add: expected %d got %d", addReply.C, args.A+args.B)
@@ -138,7 +138,7 @@ func TestClient(t *testing.T) {
mulCall = <-mulCall.Done
if mulCall.Error != nil {
- t.Errorf("Mul: expected no error but got string %q", mulCall.Error.String())
+ t.Errorf("Mul: expected no error but got string %q", mulCall.Error.Error())
}
if mulReply.C != args.A*args.B {
t.Errorf("Mul: expected %d got %d", mulReply.C, args.A*args.B)
@@ -151,7 +151,7 @@ func TestClient(t *testing.T) {
// expect an error: zero divide
if err == nil {
t.Error("Div: expected error")
- } else if err.String() != "divide by zero" {
+ } else if err.Error() != "divide by zero" {
t.Error("Div: expected divide by zero error; got", err)
}
}
@@ -164,8 +164,8 @@ func TestMalformedInput(t *testing.T) {
func TestUnexpectedError(t *testing.T) {
cli, srv := myPipe()
- go cli.PipeWriter.CloseWithError(os.NewError("unexpected error!")) // reader will get this error
- ServeConn(srv) // must return, not loop
+ go cli.PipeWriter.CloseWithError(errors.New("unexpected error!")) // reader will get this error
+ ServeConn(srv) // must return, not loop
}
// Copied from package net.
@@ -191,7 +191,7 @@ func (pipeAddr) String() string {
return "pipe"
}
-func (p *pipe) Close() os.Error {
+func (p *pipe) Close() error {
err := p.PipeReader.Close()
err1 := p.PipeWriter.Close()
if err == nil {
@@ -208,14 +208,14 @@ func (p *pipe) RemoteAddr() net.Addr {
return pipeAddr(0)
}
-func (p *pipe) SetTimeout(nsec int64) os.Error {
- return os.NewError("net.Pipe does not support timeouts")
+func (p *pipe) SetTimeout(nsec int64) error {
+ return errors.New("net.Pipe does not support timeouts")
}
-func (p *pipe) SetReadTimeout(nsec int64) os.Error {
- return os.NewError("net.Pipe does not support timeouts")
+func (p *pipe) SetReadTimeout(nsec int64) error {
+ return errors.New("net.Pipe does not support timeouts")
}
-func (p *pipe) SetWriteTimeout(nsec int64) os.Error {
- return os.NewError("net.Pipe does not support timeouts")
+func (p *pipe) SetWriteTimeout(nsec int64) error {
+ return errors.New("net.Pipe does not support timeouts")
}