test(number): cover zero-prefixable exponent digits
Assisted-by: GLM 5.3
This commit is contained in:
@@ -421,6 +421,10 @@ func TestAcceptsNumberEdgeCases(t *testing.T) {
|
||||
"3.14": 3.14,
|
||||
"6.022e23": 6.022e23,
|
||||
"1e10": 1e10,
|
||||
"1e0": 1.0,
|
||||
"1e06": 1e6,
|
||||
"0e00": 0.0,
|
||||
"2E-3": 2e-3,
|
||||
"-2.5E-3": -2.5e-3,
|
||||
}
|
||||
for tok, want := range cases {
|
||||
|
||||
@@ -104,7 +104,9 @@ func decodeFloat(tok string) (any, error) {
|
||||
build += "." + fp
|
||||
}
|
||||
// The ABNF requires at least one digit after the exponent marker, so a
|
||||
// trailing e or E is an error even though strconv would accept it.
|
||||
// trailing e or E is an error even though strconv would accept it. The
|
||||
// digits are a zero-prefixable integer, so leading zeros are fine here
|
||||
// (the corpus holds valid cases such as 1e06 and 0e00).
|
||||
if hasExp {
|
||||
esign, edigits := splitSign(exp)
|
||||
ed, err := joinDigits(edigits, isDecDigit)
|
||||
|
||||
Reference in New Issue
Block a user