fix: f64 转字符串 ryu 路径负数改追加防破坏非空缓冲前缀

This commit is contained in:
2026-08-15 17:35:27 +08:00
parent 9a7fe9777d
commit 5fbc0ccda5
5 changed files with 78 additions and 6 deletions
+10
View File
@@ -115,6 +115,16 @@ fn json_stringify_array() {
assert_eq!(s, "[1,2,3]");
}
#[test]
fn json_stringify_array_with_negative_double() {
// 数组内负 double:out 已含 "[1,",负号必须追加在当前数前(ryu 路径)。
let mut vm = Vm::new();
let result = eval(&mut vm, "JSON.stringify([1,-1.5])").unwrap();
assert!(result.is_string());
let s = string_value(&vm, result);
assert_eq!(s, "[1,-1.5]");
}
#[test]
fn json_stringify_string() {
let mut vm = Vm::new();