Update PrettyPrinter to better check for an Object

Includes test case to fix FF as suggested by @ondras
Fixes #409
This commit is contained in:
Sheel Choksi
2013-08-03 11:49:20 -07:00
parent 4c4317b80e
commit 0f42f2709a
3 changed files with 9 additions and 2 deletions

View File

@@ -1323,7 +1323,7 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('Date(' + value + ')');
} else if (value.__Jasmine_been_here_before__) {
this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
} else if (j$.isArray_(value) || typeof value == 'object') {
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {
value.__Jasmine_been_here_before__ = true;
if (j$.isArray_(value)) {
this.emitArray(value);

View File

@@ -5,4 +5,11 @@ describe("j$.pp (HTML Dependent)", function () {
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
expect(j$.pp({foo: sampleNode})).toEqual("{ foo : HTMLNode }");
});
it("should print Firefox's wrapped native objects correctly", function() {
if(jasmine.getEnv().firefoxVersion) {
try { new CustomEvent(); } catch(e) { var err = e; };
expect(j$.pp(err)).toMatch(/Exception.*Not enough arguments/);
}
});
});

View File

@@ -29,7 +29,7 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('Date(' + value + ')');
} else if (value.__Jasmine_been_here_before__) {
this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
} else if (j$.isArray_(value) || typeof value == 'object') {
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {
value.__Jasmine_been_here_before__ = true;
if (j$.isArray_(value)) {
this.emitArray(value);