diff --git a/lib/ace/test/asyncjs/assert.js b/lib/ace/test/asyncjs/assert.js index 0972a8d1..198da4b2 100644 --- a/lib/ace/test/asyncjs/assert.js +++ b/lib/ace/test/asyncjs/assert.js @@ -53,14 +53,21 @@ assert.AssertionError = function AssertionError(options) { }; oop.inherits(assert.AssertionError, Error); +toJSON = function(obj) { + if (typeof JSON !== "undefined") + return JSON.stringify(obj); + else + return obj.toString(); +} + assert.AssertionError.prototype.toString = function() { if (this.message) { return [this.name + ':', this.message].join(' '); } else { return [this.name + ':', - JSON.stringify(this.expected), + toJSON(this.expected), this.operator, - JSON.stringify(this.actual)].join(' '); + toJSON(this.actual)].join(' '); } };