diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
commit | 2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch) | |
tree | 7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/testing | |
parent | 02e9018f1616b23f1276151797216717b3564202 (diff) | |
download | gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.zip gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.gz gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.bz2 |
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/testing')
-rw-r--r-- | libgo/go/testing/benchmark.go | 4 | ||||
-rw-r--r-- | libgo/go/testing/example.go | 2 | ||||
-rw-r--r-- | libgo/go/testing/iotest/logger.go | 5 | ||||
-rw-r--r-- | libgo/go/testing/iotest/reader.go | 12 | ||||
-rw-r--r-- | libgo/go/testing/iotest/writer.go | 7 | ||||
-rw-r--r-- | libgo/go/testing/quick/quick.go | 13 | ||||
-rw-r--r-- | libgo/go/testing/quick/quick_test.go | 3 | ||||
-rw-r--r-- | libgo/go/testing/script/script.go | 11 | ||||
-rw-r--r-- | libgo/go/testing/testing.go | 6 |
9 files changed, 28 insertions, 35 deletions
diff --git a/libgo/go/testing/benchmark.go b/libgo/go/testing/benchmark.go index fd0bd86..df4c4a1 100644 --- a/libgo/go/testing/benchmark.go +++ b/libgo/go/testing/benchmark.go @@ -197,7 +197,7 @@ func (r BenchmarkResult) String() string { // An internal function but exported because it is cross-package; part of the implementation // of gotest. -func RunBenchmarks(matchString func(pat, str string) (bool, os.Error), benchmarks []InternalBenchmark) { +func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark) { // If no flag was specified, don't run benchmarks. if len(*matchBenchmarks) == 0 { return @@ -205,7 +205,7 @@ func RunBenchmarks(matchString func(pat, str string) (bool, os.Error), benchmark for _, Benchmark := range benchmarks { matched, err := matchString(*matchBenchmarks, Benchmark.Name) if err != nil { - println("invalid regexp for -test.bench:", err.String()) + println("invalid regexp for -test.bench:", err.Error()) os.Exit(1) } if !matched { diff --git a/libgo/go/testing/example.go b/libgo/go/testing/example.go index f148951..5b3e322 100644 --- a/libgo/go/testing/example.go +++ b/libgo/go/testing/example.go @@ -25,7 +25,7 @@ func RunExamples(examples []InternalExample) (ok bool) { defer func() { os.Stdout, os.Stderr = stdout, stderr if e := recover(); e != nil { - if err, ok := e.(os.Error); ok { + if err, ok := e.(error); ok { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/libgo/go/testing/iotest/logger.go b/libgo/go/testing/iotest/logger.go index c3bf5df..1475d9b0 100644 --- a/libgo/go/testing/iotest/logger.go +++ b/libgo/go/testing/iotest/logger.go @@ -7,7 +7,6 @@ package iotest import ( "io" "log" - "os" ) type writeLogger struct { @@ -15,7 +14,7 @@ type writeLogger struct { w io.Writer } -func (l *writeLogger) Write(p []byte) (n int, err os.Error) { +func (l *writeLogger) Write(p []byte) (n int, err error) { n, err = l.w.Write(p) if err != nil { log.Printf("%s %x: %v", l.prefix, p[0:n], err) @@ -37,7 +36,7 @@ type readLogger struct { r io.Reader } -func (l *readLogger) Read(p []byte) (n int, err os.Error) { +func (l *readLogger) Read(p []byte) (n int, err error) { n, err = l.r.Read(p) if err != nil { log.Printf("%s %x: %v", l.prefix, p[0:n], err) diff --git a/libgo/go/testing/iotest/reader.go b/libgo/go/testing/iotest/reader.go index dcf5565..ab8dc31 100644 --- a/libgo/go/testing/iotest/reader.go +++ b/libgo/go/testing/iotest/reader.go @@ -6,8 +6,8 @@ package iotest import ( + "errors" "io" - "os" ) // OneByteReader returns a Reader that implements @@ -18,7 +18,7 @@ type oneByteReader struct { r io.Reader } -func (r *oneByteReader) Read(p []byte) (int, os.Error) { +func (r *oneByteReader) Read(p []byte) (int, error) { if len(p) == 0 { return 0, nil } @@ -33,7 +33,7 @@ type halfReader struct { r io.Reader } -func (r *halfReader) Read(p []byte) (int, os.Error) { +func (r *halfReader) Read(p []byte) (int, error) { return r.r.Read(p[0 : (len(p)+1)/2]) } @@ -48,7 +48,7 @@ type dataErrReader struct { data []byte } -func (r *dataErrReader) Read(p []byte) (n int, err os.Error) { +func (r *dataErrReader) Read(p []byte) (n int, err error) { // loop because first call needs two reads: // one to get data and a second to look for an error. for { @@ -66,7 +66,7 @@ func (r *dataErrReader) Read(p []byte) (n int, err os.Error) { return } -var ErrTimeout = os.NewError("timeout") +var ErrTimeout = errors.New("timeout") // TimeoutReader returns ErrTimeout on the second read // with no data. Subsequent calls to read succeed. @@ -77,7 +77,7 @@ type timeoutReader struct { count int } -func (r *timeoutReader) Read(p []byte) (int, os.Error) { +func (r *timeoutReader) Read(p []byte) (int, error) { r.count++ if r.count == 2 { return 0, ErrTimeout diff --git a/libgo/go/testing/iotest/writer.go b/libgo/go/testing/iotest/writer.go index 71f504c..af61ab8 100644 --- a/libgo/go/testing/iotest/writer.go +++ b/libgo/go/testing/iotest/writer.go @@ -4,10 +4,7 @@ package iotest -import ( - "io" - "os" -) +import "io" // TruncateWriter returns a Writer that writes to w // but stops silently after n bytes. @@ -20,7 +17,7 @@ type truncateWriter struct { n int64 } -func (t *truncateWriter) Write(p []byte) (n int, err os.Error) { +func (t *truncateWriter) Write(p []byte) (n int, err error) { if t.n <= 0 { return len(p), nil } diff --git a/libgo/go/testing/quick/quick.go b/libgo/go/testing/quick/quick.go index 9ec1925..9e6b84b 100644 --- a/libgo/go/testing/quick/quick.go +++ b/libgo/go/testing/quick/quick.go @@ -9,7 +9,6 @@ import ( "flag" "fmt" "math" - "os" "rand" "reflect" "strings" @@ -191,7 +190,7 @@ func (c *Config) getMaxCount() (maxCount int) { // used, independent of the functions being tested. type SetupError string -func (s SetupError) String() string { return string(s) } +func (s SetupError) Error() string { return string(s) } // A CheckError is the result of Check finding an error. type CheckError struct { @@ -199,7 +198,7 @@ type CheckError struct { In []interface{} } -func (s *CheckError) String() string { +func (s *CheckError) Error() string { return fmt.Sprintf("#%d: failed on input %s", s.Count, toString(s.In)) } @@ -210,7 +209,7 @@ type CheckEqualError struct { Out2 []interface{} } -func (s *CheckEqualError) String() string { +func (s *CheckEqualError) Error() string { return fmt.Sprintf("#%d: failed on input %s. Output 1: %s. Output 2: %s", s.Count, toString(s.In), toString(s.Out1), toString(s.Out2)) } @@ -229,7 +228,7 @@ func (s *CheckEqualError) String() string { // t.Error(err) // } // } -func Check(function interface{}, config *Config) (err os.Error) { +func Check(function interface{}, config *Config) (err error) { if config == nil { config = &defaultConfig } @@ -272,7 +271,7 @@ func Check(function interface{}, config *Config) (err os.Error) { // It calls f and g repeatedly with arbitrary values for each argument. // If f and g return different answers, CheckEqual returns a *CheckEqualError // describing the input and the outputs. -func CheckEqual(f, g interface{}, config *Config) (err os.Error) { +func CheckEqual(f, g interface{}, config *Config) (err error) { if config == nil { config = &defaultConfig } @@ -317,7 +316,7 @@ func CheckEqual(f, g interface{}, config *Config) (err os.Error) { // arbitraryValues writes Values to args such that args contains Values // suitable for calling f. -func arbitraryValues(args []reflect.Value, f reflect.Type, config *Config, rand *rand.Rand) (err os.Error) { +func arbitraryValues(args []reflect.Value, f reflect.Type, config *Config, rand *rand.Rand) (err error) { if config.Values != nil { config.Values(args, rand) return diff --git a/libgo/go/testing/quick/quick_test.go b/libgo/go/testing/quick/quick_test.go index f2618c3..e9ff1aa 100644 --- a/libgo/go/testing/quick/quick_test.go +++ b/libgo/go/testing/quick/quick_test.go @@ -8,7 +8,6 @@ import ( "rand" "reflect" "testing" - "os" ) func fBool(a bool) bool { return a } @@ -63,7 +62,7 @@ func fIntptr(a *int) *int { return &b } -func reportError(property string, err os.Error, t *testing.T) { +func reportError(property string, err error, t *testing.T) { if err != nil { t.Errorf("%s: %s", property, err) } diff --git a/libgo/go/testing/script/script.go b/libgo/go/testing/script/script.go index afb286f..98f3625 100644 --- a/libgo/go/testing/script/script.go +++ b/libgo/go/testing/script/script.go @@ -7,7 +7,6 @@ package script import ( "fmt" - "os" "rand" "reflect" "strings" @@ -171,7 +170,7 @@ type ReceivedUnexpected struct { ready []*Event } -func (r ReceivedUnexpected) String() string { +func (r ReceivedUnexpected) Error() string { names := make([]string, len(r.ready)) for i, v := range r.ready { names[i] = v.name @@ -183,7 +182,7 @@ func (r ReceivedUnexpected) String() string { // Events. type SetupError string -func (s SetupError) String() string { return string(s) } +func (s SetupError) Error() string { return string(s) } func NewEvent(name string, predecessors []*Event, action action) *Event { e := &Event{name, false, predecessors, action} @@ -223,7 +222,7 @@ func NewEvent(name string, predecessors []*Event, action action) *Event { // the other. At each receive step, all the receive channels are considered, // thus Perform may see a value from a channel that is not in the current ready // set and fail. -func Perform(seed int64, events []*Event) (err os.Error) { +func Perform(seed int64, events []*Event) (err error) { r := rand.New(rand.NewSource(seed)) channels, err := getChannels(events) @@ -269,7 +268,7 @@ Outer: } // getChannels returns all the channels listed in any receive events. -func getChannels(events []*Event) ([]interface{}, os.Error) { +func getChannels(events []*Event) ([]interface{}, error) { channels := make([]interface{}, len(events)) j := 0 @@ -326,7 +325,7 @@ type channelRecv struct { } // readyEvents returns the subset of events that are ready. -func readyEvents(events []*Event) ([]*Event, os.Error) { +func readyEvents(events []*Event) ([]*Event, error) { ready := make([]*Event, len(events)) j := 0 diff --git a/libgo/go/testing/testing.go b/libgo/go/testing/testing.go index a555cb4..5869642c 100644 --- a/libgo/go/testing/testing.go +++ b/libgo/go/testing/testing.go @@ -173,7 +173,7 @@ func tRunner(t *T, test *InternalTest) { // An internal function but exported because it is cross-package; part of the implementation // of gotest. -func Main(matchString func(pat, str string) (bool, os.Error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) { +func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) { flag.Parse() parseCpuList() @@ -201,7 +201,7 @@ func report(t *T) { } } -func RunTests(matchString func(pat, str string) (bool, os.Error), tests []InternalTest) (ok bool) { +func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool) { ok = true if len(tests) == 0 { fmt.Fprintln(os.Stderr, "testing: warning: no tests to run") @@ -217,7 +217,7 @@ func RunTests(matchString func(pat, str string) (bool, os.Error), tests []Intern for i := 0; i < len(tests); i++ { matched, err := matchString(*match, tests[i].Name) if err != nil { - println("invalid regexp for -test.run:", err.String()) + println("invalid regexp for -test.run:", err.Error()) os.Exit(1) } if !matched { |