diff mbox

libgo patch committed: Fix json test when rand returns 0

Message ID mcrr5636yql.fsf@coign.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor July 6, 2011, 6:38 p.m. UTC
This patch is necessary when compiling the test cases with optimization,
which changes the order of the calls to rand.  I proposed the same patch
to the upstream library.  Bootstrapped and tested on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 48658f7ed377 libgo/go/json/scanner_test.go
--- a/libgo/go/json/scanner_test.go	Fri Jun 24 07:06:48 2011 -0700
+++ b/libgo/go/json/scanner_test.go	Wed Jul 06 11:35:51 2011 -0700
@@ -252,6 +252,9 @@ 
 	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)