Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rebuild distribution

  • Loading branch information...
commit 367d3dcf665cc4c56bef80a0fdfaabe79b01d68b 1 parent 21de44a
Greg Cobb and Luan Santos authored
Showing with 16 additions and 6 deletions.
  1. +15 −5 lib/jasmine-core/jasmine.js
  2. +1 −1  src/core/util.js
20 lib/jasmine-core/jasmine.js
View
@@ -224,6 +224,16 @@ getJasmineRequireObj().util = function() {
return obj === void 0;
};
+ util.arrayContains = function(array, search) {
+ var i = array.length;
+ while (i--) {
+ if (array[i] == search) {
+ return true;
+ }
+ }
+ return false;
+ };
+
return util;
};
@@ -1407,6 +1417,7 @@ getJasmineRequireObj().pp = function(j$) {
function PrettyPrinter() {
this.ppNestLevel_ = 0;
+ this.seen = [];
}
PrettyPrinter.prototype.format = function(value) {
@@ -1434,16 +1445,16 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('HTMLNode');
} else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')');
- } else if (value.__Jasmine_been_here_before__) {
+ } else if (j$.util.arrayContains(this.seen, value)) {
this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {
- value.__Jasmine_been_here_before__ = true;
+ this.seen.push(value);
if (j$.isArray_(value)) {
this.emitArray(value);
} else {
this.emitObject(value);
}
- delete value.__Jasmine_been_here_before__;
+ this.seen.pop();
} else {
this.emitScalar(value.toString());
}
@@ -1455,7 +1466,6 @@ getJasmineRequireObj().pp = function(j$) {
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
- if (property == '__Jasmine_been_here_before__') { continue; }
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
obj.__lookupGetter__(property) !== null) : false);
}
@@ -1516,7 +1526,7 @@ getJasmineRequireObj().pp = function(j$) {
}
self.append(property);
- self.append(' : ');
+ self.append(': ');
if (isGetter) {
self.append('<getter>');
} else {
2  src/core/util.js
View
@@ -38,7 +38,7 @@ getJasmineRequireObj().util = function() {
}
}
return false;
- }
+ };
return util;
};
Please sign in to comment.
Something went wrong with that request. Please try again.