Merge branch 'toString_fallback' of https://github.com/myitcv/jasmine into myitcv-toString_fallback
This commit is contained in:
@@ -1618,6 +1618,8 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
this.emitScalar('HTMLNode');
|
||||
} else if (value instanceof Date) {
|
||||
this.emitScalar('Date(' + value + ')');
|
||||
} else if (value.toString && typeof value === 'object' && !(value instanceof Array) && value.toString !== Object.prototype.toString) {
|
||||
this.emitScalar(value.toString());
|
||||
} 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)) {
|
||||
|
||||
@@ -181,6 +181,14 @@ describe("j$.pp", function () {
|
||||
expect(j$.pp(obj)).toEqual("strung");
|
||||
});
|
||||
|
||||
it("should stringify objects that implement custom toString", function () {
|
||||
var obj = {
|
||||
toString: function () { return "my toString"; }
|
||||
};
|
||||
|
||||
expect(j$.pp(obj)).toEqual("my toString");
|
||||
});
|
||||
|
||||
it("should handle objects with null prototype", function() {
|
||||
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
this.emitScalar('HTMLNode');
|
||||
} else if (value instanceof Date) {
|
||||
this.emitScalar('Date(' + value + ')');
|
||||
} else if (value.toString && typeof value === 'object' && !(value instanceof Array) && value.toString !== Object.prototype.toString) {
|
||||
this.emitScalar(value.toString());
|
||||
} 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)) {
|
||||
|
||||
Reference in New Issue
Block a user