]> Cypherpunks repositories - gostls13.git/commit
testing/quick: terminate for arbitrary recursive types
authorHÃ¥vard Haugen <havard.haugen@gmail.com>
Tue, 9 Jun 2015 22:30:32 +0000 (00:30 +0200)
committerAdam Langley <agl@golang.org>
Sat, 29 Aug 2015 19:23:37 +0000 (19:23 +0000)
commit74245b03534dfec5f719aa60e03c0b932aa63e26
treecaf71a9dc0825c689ff35faef74a3be15369d1ca
parentea0491b70a82a207a951f869c7c1e5a52dbf410f
testing/quick: terminate for arbitrary recursive types

Recursive types R containing slices of R's did not terminate despite the
effort in CL 10821.

For recursive types there was a competition between slice expansion by a
factor 'complexSize', and termination with probability '1/complexSize'
which lead to stack overflow as soon as a recursive struct had slices
pointing to its own type.

Fix this by shrinking the size hint as a function of recursion depth.
This has the dual effect of reducing the number of elements generated
per slice and also increasing the probability for termination.

Fixes #11148.

Change-Id: Ib61155b4f2e2de3873d508d63a1f4be759426d67
Reviewed-on: https://go-review.googlesource.com/13830
Reviewed-by: Adam Langley <agl@golang.org>
src/testing/quick/quick.go
src/testing/quick/quick_test.go