mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-24 02:36:48 -06:00
Reject unmatched '.' and ',' in NUMBERVALUE text
Found while testing crates/functions/src/text.rs:326-340 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
b8771d51fb
commit
b47c83f6aa
@@ -334,6 +334,8 @@ fn numbervalue(a: &[Arg], c: &mut dyn Ctx) -> R<Value> {
|
||||
if seen_dec {
|
||||
return Err(CellError::Value);
|
||||
}
|
||||
} else if c == '.' || c == ',' {
|
||||
return Err(CellError::Value);
|
||||
} else {
|
||||
out.push(c);
|
||||
}
|
||||
@@ -1216,6 +1218,8 @@ mod tests {
|
||||
close(ev("NUMBERVALUE", vec![t(" 1 000 ")]), 1000.0);
|
||||
close(ev("NUMBERVALUE", vec![t("")]), 0.0);
|
||||
is_err(ev("NUMBERVALUE", vec![t("1.2.3")]), CellError::Value);
|
||||
is_err(ev("NUMBERVALUE", vec![t("1.5"), t(","), t(" ")]), CellError::Value);
|
||||
is_err(ev("NUMBERVALUE", vec![t("1,5"), t("."), t(" ")]), CellError::Value);
|
||||
is_text(ev("FIXED", vec![n(1234.567), n(1.0)]), "1,234.6");
|
||||
is_text(ev("FIXED", vec![n(1234.567), n(-1.0)]), "1,230");
|
||||
is_text(ev("FIXED", vec![n(-1234.567), n(1.0), b(true)]), "-1234.6");
|
||||
|
||||
Reference in New Issue
Block a user