json: fix test when rand returns 0.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 6 Jul 2011 18:38:24 +0000 (18:38 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 6 Jul 2011 18:38:24 +0000 (18:38 +0000)
Fixes using gccgo when optimizing, which changes the order of
calls to rand.  Same patch proposed upstream.

From-SVN: r175927

libgo/go/json/scanner_test.go

index 0d4de3246dd0fa4000df0b67acff73c4c42db420..df87c716aff2269d34883488ee1813be0a03f734 100644 (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)