mirror of
https://github.com/chaijs/chai
synced 2024-11-15 08:17:14 +00:00
Merge pull request #298 from dasilvacontin/negativeZeroLogging
added check for logging negative zero
This commit is contained in:
commit
3e35adff93
2 changed files with 11 additions and 0 deletions
|
@ -191,6 +191,9 @@ function formatPrimitive(ctx, value) {
|
||||||
return ctx.stylize(simple, 'string');
|
return ctx.stylize(simple, 'string');
|
||||||
|
|
||||||
case 'number':
|
case 'number':
|
||||||
|
if (value === 0 && (1/value) === -Infinity) {
|
||||||
|
return ctx.stylize('-0', 'number');
|
||||||
|
}
|
||||||
return ctx.stylize('' + value, 'number');
|
return ctx.stylize('' + value, 'number');
|
||||||
|
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
|
|
|
@ -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 () {
|
it('addChainableMethod', function () {
|
||||||
chai.use(function (_chai, _) {
|
chai.use(function (_chai, _) {
|
||||||
_chai.Assertion.addChainableMethod('x',
|
_chai.Assertion.addChainableMethod('x',
|
||||||
|
|
Loading…
Reference in a new issue