| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8d2858a commit 7993e3e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1917,11 +1917,12 @@ function addNumericSeparatorEnd(integerString) { | |||
| 1917 | 1917 | const remainingText = (remaining) => `... ${remaining} more item${remaining > 1 ? 's' : ''}`; | |
| 1918 | 1918 | ||
| 1919 | 1919 | function formatNumber(fn, number, numericSeparator) { | |
| 1920 | + // Format -0 as '-0'. Checking `number === -0` won't distinguish 0 from -0. | ||
| 1921 | + // String(-0) === '0', so this must be checked before any String() conversion. | ||
| 1922 | + if (ObjectIs(number, -0)) { | ||
| 1923 | + return fn('-0', 'number'); | ||
| 1924 | + } | ||
| 1920 | 1925 | if (!numericSeparator) { | |
| 1921 | - // Format -0 as '-0'. Checking `number === -0` won't distinguish 0 from -0. | ||
| 1922 | - if (ObjectIs(number, -0)) { | ||
| 1923 | - return fn('-0', 'number'); | ||
| 1924 | - } | ||
| 1925 | 1926 | return fn(`${number}`, 'number'); | |
| 1926 | 1927 | } | |
| 1927 | 1928 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3793,6 +3793,7 @@ assert.strictEqual( | |||
| 3793 | 3793 | assert.strictEqual(util.inspect(NaN), 'NaN'); | |
| 3794 | 3794 | assert.strictEqual(util.inspect(Infinity), 'Infinity'); | |
| 3795 | 3795 | assert.strictEqual(util.inspect(-Infinity), '-Infinity'); | |
| 3796 | + assert.strictEqual(util.inspect(-0), '-0'); | ||
| 3796 | 3797 | ||
| 3797 | 3798 | assert.strictEqual( | |
| 3798 | 3799 | util.inspect(new Float64Array([100_000_000])), | |
@@ -3824,6 +3825,9 @@ assert.strictEqual( | |||
| 3824 | 3825 | '-123_456_789.123_456_78' | |
| 3825 | 3826 | ); | |
| 3826 | 3827 | ||
| 3828 | + // -0 should be formatted as '-0' even with numericSeparator enabled | ||
| 3829 | + assert.strictEqual(util.inspect(-0, { numericSeparator: true }), '-0'); | ||
| 3830 | + | ||
| 3827 | 3831 | // Regression test for https://github.com/nodejs/node/issues/59376 | |
| 3828 | 3832 | // numericSeparator should work correctly for negative fractional numbers | |
| 3829 | 3833 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments