From 367d3dcf665cc4c56bef80a0fdfaabe79b01d68b Mon Sep 17 00:00:00 2001 From: Greg Cobb and Luan Santos Date: Wed, 12 Mar 2014 11:51:49 -0700 Subject: [PATCH] Rebuild distribution --- lib/jasmine-core/jasmine.js | 20 +++++++++++++++----- src/core/util.js | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 50e3d6f1..7cb27026 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -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(''); } 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(''); } else { diff --git a/src/core/util.js b/src/core/util.js index 64ad1e33..fa9ef13a 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -38,7 +38,7 @@ getJasmineRequireObj().util = function() { } } return false; - } + }; return util; };