[dev.fuzz] internal/fuzz: allow float types to be integer literals

Previously, something like `float64(0)` would fail to decode
since the 0 value is considered an integer literal, and the
float64 parsing code required a float literal. Be more flexible
here since an integer can always be converted to a float.

Change-Id: Id1c53ef2e8a9748a4f71176b00b453a329af4ade
Reviewed-on: https://go-review.googlesource.com/c/go/+/309032
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Katie Hockman 2021-04-09 15:50:40 -04:00
parent 88c0c2d9ea
commit 8b96efd8a2
2 changed files with 11 additions and 4 deletions

View file

@ -72,6 +72,13 @@ string("extra")
},
{
in: `go test fuzz v1
float64(0)
float32(0)
`,
ok: true, // will be an integer literal since there is no decimal
},
{
in: `go test fuzz v1
int(-23)
int8(-2)
int64(2342425)