1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

fix: display "-0" for -0 (#2281)

Added special handling code in js/console.ts
This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2019-05-03 11:01:20 -07:00 committed by Ryan Dahl
parent 52830414da
commit 6929aba71d
2 changed files with 3 additions and 0 deletions

View file

@ -122,6 +122,8 @@ function stringify(
case "string":
return value;
case "number":
// Special handling of -0
return Object.is(value, -0) ? "-0" : `${value}`;
case "boolean":
case "undefined":
case "symbol":

View file

@ -100,6 +100,7 @@ test(function consoleTestStringifyCircular(): void {
const nestedObjExpected = `{ num, bool, str, method, asyncMethod, generatorMethod, un, nu, arrowFunc, extendedClass, nFunc, extendedCstr, o }`;
assertEquals(stringify(1), "1");
assertEquals(stringify(-0), "-0");
assertEquals(stringify(1n), "1n");
assertEquals(stringify("s"), "s");
assertEquals(stringify(false), "false");