Patchwork libgo patch committed: Fix json test when rand returns 0

login
register
mail settings
Submitter Ian Taylor
Date July 6, 2011, 6:38 p.m.
Message ID <mcrr5636yql.fsf@coign.corp.google.com>
Download mbox | patch
Permalink /patch/103567/
State New
Headers show

Comments

Ian Taylor - July 6, 2011, 6:38 p.m.
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

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)