mirror of
https://github.com/chaijs/chai
synced 2024-11-15 00:07:11 +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');
|
||||
|
||||
case 'number':
|
||||
if (value === 0 && (1/value) === -Infinity) {
|
||||
return ctx.stylize('-0', 'number');
|
||||
}
|
||||
return ctx.stylize('' + value, 'number');
|
||||
|
||||
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 () {
|
||||
chai.use(function (_chai, _) {
|
||||
_chai.Assertion.addChainableMethod('x',
|
||||
|
|
Loading…
Reference in a new issue