test(number): cover zero-prefixable exponent digits

Assisted-by: GLM 5.3
This commit is contained in:
2026-09-17 23:05:27 +02:00
parent 830f840f44
commit 3c1f65038b
2 changed files with 7 additions and 1 deletions
+4
View File
@@ -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 {
+3 -1
View File
@@ -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)