summaryrefslogtreecommitdiff
path: root/src/pkg/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/testing')
-rw-r--r--src/pkg/testing/iotest/reader.go3
-rw-r--r--src/pkg/testing/quick/quick.go44
-rw-r--r--src/pkg/testing/quick/quick_test.go2
-rw-r--r--src/pkg/testing/script/script.go14
-rw-r--r--src/pkg/testing/testing.go2
5 files changed, 32 insertions, 33 deletions
diff --git a/src/pkg/testing/iotest/reader.go b/src/pkg/testing/iotest/reader.go
index 647520a09..e4003d744 100644
--- a/src/pkg/testing/iotest/reader.go
+++ b/src/pkg/testing/iotest/reader.go
@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The iotest package implements Readers and Writers
-// useful only for testing.
+// Package iotest implements Readers and Writers useful only for testing.
package iotest
import (
diff --git a/src/pkg/testing/quick/quick.go b/src/pkg/testing/quick/quick.go
index 52fd38d9c..756a60e13 100644
--- a/src/pkg/testing/quick/quick.go
+++ b/src/pkg/testing/quick/quick.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This package implements utility functions to help with black box testing.
+// Package quick implements utility functions to help with black box testing.
package quick
import (
@@ -59,37 +59,37 @@ func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
switch concrete := t; concrete.Kind() {
case reflect.Bool:
- return reflect.NewValue(rand.Int()&1 == 0), true
+ return reflect.ValueOf(rand.Int()&1 == 0), true
case reflect.Float32:
- return reflect.NewValue(randFloat32(rand)), true
+ return reflect.ValueOf(randFloat32(rand)), true
case reflect.Float64:
- return reflect.NewValue(randFloat64(rand)), true
+ return reflect.ValueOf(randFloat64(rand)), true
case reflect.Complex64:
- return reflect.NewValue(complex(randFloat32(rand), randFloat32(rand))), true
+ return reflect.ValueOf(complex(randFloat32(rand), randFloat32(rand))), true
case reflect.Complex128:
- return reflect.NewValue(complex(randFloat64(rand), randFloat64(rand))), true
+ return reflect.ValueOf(complex(randFloat64(rand), randFloat64(rand))), true
case reflect.Int16:
- return reflect.NewValue(int16(randInt64(rand))), true
+ return reflect.ValueOf(int16(randInt64(rand))), true
case reflect.Int32:
- return reflect.NewValue(int32(randInt64(rand))), true
+ return reflect.ValueOf(int32(randInt64(rand))), true
case reflect.Int64:
- return reflect.NewValue(randInt64(rand)), true
+ return reflect.ValueOf(randInt64(rand)), true
case reflect.Int8:
- return reflect.NewValue(int8(randInt64(rand))), true
+ return reflect.ValueOf(int8(randInt64(rand))), true
case reflect.Int:
- return reflect.NewValue(int(randInt64(rand))), true
+ return reflect.ValueOf(int(randInt64(rand))), true
case reflect.Uint16:
- return reflect.NewValue(uint16(randInt64(rand))), true
+ return reflect.ValueOf(uint16(randInt64(rand))), true
case reflect.Uint32:
- return reflect.NewValue(uint32(randInt64(rand))), true
+ return reflect.ValueOf(uint32(randInt64(rand))), true
case reflect.Uint64:
- return reflect.NewValue(uint64(randInt64(rand))), true
+ return reflect.ValueOf(uint64(randInt64(rand))), true
case reflect.Uint8:
- return reflect.NewValue(uint8(randInt64(rand))), true
+ return reflect.ValueOf(uint8(randInt64(rand))), true
case reflect.Uint:
- return reflect.NewValue(uint(randInt64(rand))), true
+ return reflect.ValueOf(uint(randInt64(rand))), true
case reflect.Uintptr:
- return reflect.NewValue(uintptr(randInt64(rand))), true
+ return reflect.ValueOf(uintptr(randInt64(rand))), true
case reflect.Map:
numElems := rand.Intn(complexSize)
m := reflect.MakeMap(concrete)
@@ -107,8 +107,8 @@ func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
if !ok {
return reflect.Value{}, false
}
- p := reflect.Zero(concrete)
- p.Set(v.Addr())
+ p := reflect.New(concrete.Elem())
+ p.Elem().Set(v)
return p, true
case reflect.Slice:
numElems := rand.Intn(complexSize)
@@ -127,9 +127,9 @@ func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
for i := 0; i < numChars; i++ {
codePoints[i] = rand.Intn(0x10ffff)
}
- return reflect.NewValue(string(codePoints)), true
+ return reflect.ValueOf(string(codePoints)), true
case reflect.Struct:
- s := reflect.Zero(t)
+ s := reflect.New(t).Elem()
for i := 0; i < s.NumField(); i++ {
v, ok := Value(concrete.Field(i).Type, rand)
if !ok {
@@ -336,7 +336,7 @@ func arbitraryValues(args []reflect.Value, f reflect.Type, config *Config, rand
}
func functionAndType(f interface{}) (v reflect.Value, t reflect.Type, ok bool) {
- v = reflect.NewValue(f)
+ v = reflect.ValueOf(f)
ok = v.Kind() == reflect.Func
if !ok {
return
diff --git a/src/pkg/testing/quick/quick_test.go b/src/pkg/testing/quick/quick_test.go
index b126e4a16..f2618c3c2 100644
--- a/src/pkg/testing/quick/quick_test.go
+++ b/src/pkg/testing/quick/quick_test.go
@@ -102,7 +102,7 @@ type myStruct struct {
}
func (m myStruct) Generate(r *rand.Rand, _ int) reflect.Value {
- return reflect.NewValue(myStruct{x: 42})
+ return reflect.ValueOf(myStruct{x: 42})
}
func myStructProperty(in myStruct) bool { return in.x == 42 }
diff --git a/src/pkg/testing/script/script.go b/src/pkg/testing/script/script.go
index b18018497..afb286f5b 100644
--- a/src/pkg/testing/script/script.go
+++ b/src/pkg/testing/script/script.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This package aids in the testing of code that uses channels.
+// Package script aids in the testing of code that uses channels.
package script
import (
@@ -134,19 +134,19 @@ type empty struct {
}
func newEmptyInterface(e empty) reflect.Value {
- return reflect.NewValue(e).Field(0)
+ return reflect.ValueOf(e).Field(0)
}
func (s Send) send() {
// With reflect.ChanValue.Send, we must match the types exactly. So, if
// s.Channel is a chan interface{} we convert s.Value to an interface{}
// first.
- c := reflect.NewValue(s.Channel)
+ c := reflect.ValueOf(s.Channel)
var v reflect.Value
if iface := c.Type().Elem(); iface.Kind() == reflect.Interface && iface.NumMethod() == 0 {
v = newEmptyInterface(empty{s.Value})
} else {
- v = reflect.NewValue(s.Value)
+ v = reflect.ValueOf(s.Value)
}
c.Send(v)
}
@@ -162,7 +162,7 @@ func (s Close) getSend() sendAction { return s }
func (s Close) getChannel() interface{} { return s.Channel }
-func (s Close) send() { reflect.NewValue(s.Channel).Close() }
+func (s Close) send() { reflect.ValueOf(s.Channel).Close() }
// A ReceivedUnexpected error results if no active Events match a value
// received from a channel.
@@ -278,7 +278,7 @@ func getChannels(events []*Event) ([]interface{}, os.Error) {
continue
}
c := event.action.getChannel()
- if reflect.NewValue(c).Kind() != reflect.Chan {
+ if reflect.ValueOf(c).Kind() != reflect.Chan {
return nil, SetupError("one of the channel values is not a channel")
}
@@ -303,7 +303,7 @@ func getChannels(events []*Event) ([]interface{}, os.Error) {
// channel repeatedly, wrapping them up as either a channelRecv or
// channelClosed structure, and forwards them to the multiplex channel.
func recvValues(multiplex chan<- interface{}, channel interface{}) {
- c := reflect.NewValue(channel)
+ c := reflect.ValueOf(channel)
for {
v, ok := c.Recv()
diff --git a/src/pkg/testing/testing.go b/src/pkg/testing/testing.go
index 1e65528ef..8781b207d 100644
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The testing package provides support for automated testing of Go packages.
+// Package testing provides support for automated testing of Go packages.
// It is intended to be used in concert with the ``gotest'' utility, which automates
// execution of any function of the form
// func TestXxx(*testing.T)