Merge pull request #298 from dasilvacontin/negativeZeroLogging

added check for logging negative zero
This commit is contained in:
Keith Cirkel 2014-11-03 12:03:52 +00:00
commit 3e35adff93
2 changed files with 11 additions and 0 deletions

View file

@ -191,6 +191,9 @@ function formatPrimitive(ctx, value) {
return ctx.stylize(simple, 'string');
case 'number':
if (value === 0 && (1/value) === -Infinity) {
return ctx.stylize('-0', 'number');
}
return ctx.stylize('' + value, 'number');
case 'boolean':

View file

@ -239,6 +239,14 @@ describe('utilities', function () {
});
});
it('inspect negative zero', function () {
chai.use(function (_chai, _) {
expect(_.inspect(-0)).to.equal('-0');
expect(_.inspect([-0])).to.equal('[ -0 ]');
expect(_.inspect({ hp: -0 })).to.equal('{ hp: -0 }');
});
});
it('addChainableMethod', function () {
chai.use(function (_chai, _) {
_chai.Assertion.addChainableMethod('x',