Updates pretty printer to include array properties

[fixes #766][finishes #87644044]
This commit is contained in:
Greg Cobb and Gregg Van Hove
2015-02-04 11:02:53 -08:00
parent 2ab2a83a3b
commit d5dfbc98c3
3 changed files with 111 additions and 39 deletions

View File

@@ -93,6 +93,23 @@ getJasmineRequireObj().pp = function(j$) {
if(array.length > length){
this.append(', ...');
}
var self = this;
var first = array.length === 0;
this.iterateObject(array, function(property, isGetter) {
if (property.match(/^\d+$/)) {
return;
}
if (first) {
first = false;
} else {
self.append(', ');
}
self.formatProperty(array, property, isGetter);
});
this.append(' ]');
};
@@ -115,18 +132,22 @@ getJasmineRequireObj().pp = function(j$) {
self.append(', ');
}
self.append(property);
self.append(': ');
if (isGetter) {
self.append('<getter>');
} else {
self.format(obj[property]);
}
self.formatProperty(obj, property, isGetter);
});
this.append(' })');
};
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
this.append(property);
this.append(': ');
if (isGetter) {
this.append('<getter>');
} else {
this.format(obj[property]);
}
};
StringPrettyPrinter.prototype.append = function(value) {
this.string += value;
};