aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2011-07-06 13:00:54 -0700
committerIan Lance Taylor <iant@golang.org>2011-07-06 13:00:54 -0700
commit7b0bb48056a59d3829ee47ab853b282d38b1efd1 (patch)
tree9691648c342637be032b51189febd102b9b23647
parent6732bd35266c0fa9fa7d88eef93d4fc344edf193 (diff)
downloadgo-7b0bb48056a59d3829ee47ab853b282d38b1efd1.tar.gz
go-7b0bb48056a59d3829ee47ab853b282d38b1efd1.zip
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
-rw-r--r--src/pkg/json/scanner_test.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/json/scanner_test.go b/src/pkg/json/scanner_test.go
index 0d4de3246d..023e7c81ee 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)
}