1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:40:23 -07:00

doc: mention testing/quick RNG seeding change in Go 1.9 notes

Also reword the testing/quick.Config field docs to conform to the
normal subject-first style. Without that style, godoc links
/pkg/testing/quick/#Config.Rand to the wrong line, since it doesn't
recognize the preceding comment as necessarily being attached.

Fixes #20809

Change-Id: I9aebbf763eed9b1ab1a153fa11850d88a65571c6
Reviewed-on: https://go-review.googlesource.com/46910
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2017-06-27 22:17:21 +00:00
parent 33b3cc1568
commit e25fdb968c
2 changed files with 23 additions and 14 deletions

View File

@ -786,10 +786,18 @@ CL 40331: https://golang.org/cl/40331: cmd/link,runtime/cgo: enable PT_TLS gener
<dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt> <dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt>
<dd> <dd>
<p><!-- CL 39152 --> <p><!-- CL 39152 -->
The package now chooses values in the full range when The package now chooses values in the full range when
generating <code>int64</code> and <code>uint64</code> random generating <code>int64</code> and <code>uint64</code> random
numbers; in earlier releases generated values were always numbers; in earlier releases generated values were always
limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range. limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range.
</p>
<p>
In previous releases, using a nil
<a href="/pkg/testing/quick/#Config.Rand"><code>Config.Rand</code></a>
value caused the same deterministic random number generator to be used.
It now uses a random number generator seeded on the current time.
For the old behavior, use <code>rand.New(rand.NewSource(0))</code>.
</p> </p>
</dl><!-- testing/quick --> </dl><!-- testing/quick -->

View File

@ -175,19 +175,20 @@ func sizedValue(t reflect.Type, rand *rand.Rand, size int) (value reflect.Value,
// A Config structure contains options for running a test. // A Config structure contains options for running a test.
type Config struct { type Config struct {
// MaxCount sets the maximum number of iterations. If zero, // MaxCount sets the maximum number of iterations.
// MaxCountScale is used. // If zero, MaxCountScale is used.
MaxCount int MaxCount int
// MaxCountScale is a non-negative scale factor applied to the default // MaxCountScale is a non-negative scale factor applied to the
// maximum. If zero, the default is unchanged. // default maximum.
// If zero, the default is unchanged.
MaxCountScale float64 MaxCountScale float64
// If non-nil, rand is a source of random numbers. Otherwise a default // Rand specifies a source of random numbers.
// pseudo-random source will be used. // If nil, a default pseudo-random source will be used.
Rand *rand.Rand Rand *rand.Rand
// If non-nil, the Values function generates a slice of arbitrary // Values specifies a function to generate a slice of
// reflect.Values that are congruent with the arguments to the function // arbitrary reflect.Values that are congruent with the
// being tested. Otherwise, the top-level Value function is used // arguments to the function being tested.
// to generate them. // If nil, the top-level Value function is used to generate them.
Values func([]reflect.Value, *rand.Rand) Values func([]reflect.Value, *rand.Rand)
} }