summaryrefslogtreecommitdiff
path: root/src/pkg/testing/quick/quick.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/testing/quick/quick.go')
-rw-r--r--src/pkg/testing/quick/quick.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/pkg/testing/quick/quick.go b/src/pkg/testing/quick/quick.go
index 756a60e13..242709822 100644
--- a/src/pkg/testing/quick/quick.go
+++ b/src/pkg/testing/quick/quick.go
@@ -9,8 +9,7 @@ import (
"flag"
"fmt"
"math"
- "os"
- "rand"
+ "math/rand"
"reflect"
"strings"
)
@@ -51,7 +50,7 @@ const complexSize = 50
// Value returns an arbitrary value of the given type.
// If the type implements the Generator interface, that will be used.
-// Note: in order to create arbitrary values for structs, all the members must be public.
+// Note: To create arbitrary values for structs, all the fields must be exported.
func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
if m, ok := reflect.Zero(t).Interface().(Generator); ok {
return m.Generate(rand, complexSize), true
@@ -123,9 +122,9 @@ func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
return s, true
case reflect.String:
numChars := rand.Intn(complexSize)
- codePoints := make([]int, numChars)
+ codePoints := make([]rune, numChars)
for i := 0; i < numChars; i++ {
- codePoints[i] = rand.Intn(0x10ffff)
+ codePoints[i] = rune(rand.Intn(0x10ffff))
}
return reflect.ValueOf(string(codePoints)), true
case reflect.Struct:
@@ -156,9 +155,10 @@ type Config struct {
// If non-nil, rand is a source of random numbers. Otherwise a default
// pseudo-random source will be used.
Rand *rand.Rand
- // If non-nil, Values is a function which generates a slice of arbitrary
- // Values that are congruent with the arguments to the function being
- // tested. Otherwise, Values is used to generate the values.
+ // If non-nil, the Values function generates a slice of arbitrary
+ // reflect.Values that are congruent with the arguments to the function
+ // being tested. Otherwise, the top-level Values function is used
+ // to generate them.
Values func([]reflect.Value, *rand.Rand)
}
@@ -191,7 +191,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 +199,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 +210,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 +229,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 +272,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 +317,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