]> Cypherpunks repositories - gostls13.git/commit
testing/quick: probabilistically generate nil pointers
authorHÃ¥vard Haugen <havard.haugen@gmail.com>
Sun, 7 Jun 2015 19:28:58 +0000 (21:28 +0200)
committerAdam Langley <agl@golang.org>
Mon, 8 Jun 2015 21:19:13 +0000 (21:19 +0000)
commit7089ea4e475a11beaed6837027b7f5254449989f
tree87def013acedd483bff00fd2b723e4e414f6f70b
parent13e2412876fb43ed4ccfca380840cdf281984f98
testing/quick: probabilistically generate nil pointers

The documentation for quick.Value says that it "returns an arbitrary
value of the given type." In spite of this, nil values for pointers were
never generated, which seems more like an oversight than an intentional
choice.

The lack of nil values meant that testing recursive type like

  type Node struct {
   Next *Node
  }

with testing/quick would lead to a stack overflow since the data
structure would never terminate.

This change may break tests that don't check for nil with pointers
returned from quick.Value. Two such instances were found in the standard
library, one of which was in the testing/quick package itself.

Fixes #8818.

Change-Id: Id390dcce649d12fbbaa801ce6f58f5defed77e60
Reviewed-on: https://go-review.googlesource.com/10821
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
src/encoding/pem/pem_test.go
src/testing/quick/quick.go
src/testing/quick/quick_test.go