fix: Negative scientific notation without decimal parts

Closes #5263
pull/24376/head
Marko Mikulicic 2022-08-02 05:36:12 +02:00
parent 8f1b6f2465
commit a926996485
1 changed files with 11 additions and 1 deletions

View File

@ -702,7 +702,7 @@ fn field_float_value_with_exponential_and_decimal(i: &str) -> IResult<&str, &str
}
fn field_float_value_with_exponential_no_decimal(i: &str) -> IResult<&str, &str> {
exponential_value(i)
recognize(preceded(opt(tag("-")), exponential_value))(i)
}
fn exponential_value(i: &str) -> IResult<&str, &str> {
@ -1485,6 +1485,16 @@ mod test {
let vals = parse(input).unwrap();
assert_eq!(vals.len(), 1);
let input = "m0 field=1e-0";
let vals = parse(input).unwrap();
assert_eq!(vals.len(), 1);
assert_eq!(vals[0].field_value("field"), Some(&FieldValue::F64(1.0)));
let input = "m0 field=-1e-0";
let vals = parse(input).unwrap();
assert_eq!(vals.len(), 1);
assert_eq!(vals[0].field_value("field"), Some(&FieldValue::F64(-1.0)));
/////////////////////
// Negative tests