Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): preserve negative zero in JSON tool output #48234

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48234/headopened View on GitHub

Showing 2 changed files with 5 additions and 0 deletions.

x
0 of 2 viewed, 2 left
4 additions and 0 deletionspackages/client-runtime/src/work-log/itemDetail.test.tsModified
View file
@@ -239,6 +239,9 @@
'{"ratio":1e-400}',
'{"price":123456789012345.6789}',
'{"ratio":0.1234567890123456789}',
+ '{"reading":-0}',
+ '{"reading":-0.0e9}',
+ "[1,-0,2]",
])("keeps %j as returned when parsing would change a number", (text) => {
expect(turnItemOutputText(toolItem({ content: [{ type: "text", text }] }))).toBe(text);
});
@@ -263,6 +266,7 @@
'[{"port":80},{"port":443,"note":"port"}]',
'{"price":1.50,"rate":25e-1}',
'{"ratio":0.00e-400}',
+ '{"reading":0,"note":"-0"}',
'{"2":1,"10":2,"a":3}',
])("still pretty-prints %j", (text) => {
expect(turnItemOutputText(toolItem({ content: [{ type: "text", text }] }))).toBe(
1 addition and 0 deletionspackages/client-runtime/src/work-log/itemDetail.tsModified
View file
@@ -205,6 +205,7 @@
const value = Number(token);
if (
!Number.isFinite(value) ||
+ Object.is(value, -0) ||
(Number.isInteger(value) && !Number.isSafeInteger(value)) ||
decimalKey(token) !== decimalKey(String(value))