Special case printing -0

Use the 1/x trick to determine if a value is -0 and special case the
printing of it.

[closes #496]
This commit is contained in:
Sheel Choksi
2014-02-09 14:14:33 -08:00
parent 83c0ea7f91
commit 7cf899a4ea
3 changed files with 5 additions and 0 deletions

View File

@@ -1354,6 +1354,8 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('undefined');
} else if (value === null) {
this.emitScalar('null');
} else if (value === 0 && 1/value === -Infinity) {
this.emitScalar('-0');
} else if (value === j$.getGlobal()) {
this.emitScalar('<global>');
} else if (value.jasmineToString) {

View File

@@ -11,6 +11,7 @@ describe("j$.pp", function () {
expect(j$.pp(jasmine.undefined)).toEqual("undefined");
expect(j$.pp(3)).toEqual("3");
expect(j$.pp(-3.14)).toEqual("-3.14");
expect(j$.pp(-0)).toEqual("-0");
});
it("should stringify arrays properly", function() {

View File

@@ -11,6 +11,8 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('undefined');
} else if (value === null) {
this.emitScalar('null');
} else if (value === 0 && 1/value === -Infinity) {
this.emitScalar('-0');
} else if (value === j$.getGlobal()) {
this.emitScalar('<global>');
} else if (value.jasmineToString) {