From 7b0bb48056a59d3829ee47ab853b282d38b1efd1 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 6 Jul 2011 13:00:54 -0700 Subject: [PATCH] json: fix test if rand returns 0. 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/json/scanner_test.go b/src/pkg/json/scanner_test.go index 0d4de3246dd..023e7c81ee4 100644 --- a/src/pkg/json/scanner_test.go +++ b/src/pkg/json/scanner_test.go @@ -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) }