json: fix test when rand returns 0.

Fixes using gccgo when optimizing, which changes the order of
calls to rand.  Same patch proposed upstream.

From-SVN: r175927
This commit is contained in:
Ian Lance Taylor 2011-07-06 18:38:24 +00:00
parent 60b4539438
commit d75dae75d7

View File

@ -252,6 +252,9 @@ func genArray(n int) []interface{} {
if f > n {
f = n
}
if n > 0 && f == 0 {
f = 1
}
x := make([]interface{}, int(f))
for i := range x {
x[i] = genValue(((i+1)*n)/f - (i*n)/f)