fix jsDump parsing

This commit is contained in:
John Bintz 2011-09-09 15:35:51 -04:00
parent dc134dcf24
commit 9c78766ded
2 changed files with 7 additions and 3 deletions

View File

@ -39,6 +39,10 @@ var jsDump;
var reName = /^function (\w+)/; var reName = /^function (\w+)/;
jsDump = { jsDump = {
doParse:function(obj) {
this.alreadySeenObjects = [];
return this.parse(obj);
},
parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance
var parser = this.parsers[ type || this.typeOf(obj) ]; var parser = this.parsers[ type || this.typeOf(obj) ];
type = typeof parser; type = typeof parser;
@ -146,7 +150,7 @@ var jsDump;
if (!this.ignoreFunctions || this.typeOf(map[key]) != 'function') { if (!this.ignoreFunctions || this.typeOf(map[key]) != 'function') {
var value = "<< LOOP >>"; var value = "<< LOOP >>";
if (this.alreadySeenObjects.indexOf(map[key]) == -1) { if ((typeof map[key] != 'object') || this.alreadySeenObjects.indexOf(map[key]) == -1) {
this.alreadySeenObjects.push(map[key]); this.alreadySeenObjects.push(map[key]);
value = this.parse(map[key]); value = this.parse(map[key]);
} }

View File

@ -40,11 +40,11 @@ module Jasmine
} catch (e) {} } catch (e) {}
if (usejsDump) { if (usejsDump) {
var dump = jsDump.parse(data); var dump = jsDump.doParse(data);
if (dump.indexOf("\\n") == -1) { if (dump.indexOf("\\n") == -1) {
JHW.log(dump); JHW.log(dump);
} else { } else {
JHW.log("jsDump: " + jsDump.parse(data)); JHW.log("jsDump: " + dump);
} }
} }
} }