]> Cypherpunks repositories - gostls13.git/commitdiff
json: fix test if rand returns 0.
authorIan Lance Taylor <iant@golang.org>
Wed, 6 Jul 2011 20:00:54 +0000 (13:00 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Jul 2011 20:00:54 +0000 (13:00 -0700)
Fixes test when run with gccgo using optimization, which
changes the order of the calls to rand.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4639101

src/pkg/json/scanner_test.go

index 0d4de3246dd0fa4000df0b67acff73c4c42db420..023e7c81ee457736adda232704dd23dd0b2c5222 100644 (file)
@@ -252,7 +252,10 @@ func genArray(n int) []interface{} {
        if f > n {
                f = n
        }
-       x := make([]interface{}, int(f))
+       if n > 0 && f == 0 {
+               f = 1
+       }
+       x := make([]interface{}, f)
        for i := range x {
                x[i] = genValue(((i+1)*n)/f - (i*n)/f)
        }