Display the name of the constructor when pretty printing objects

Fixes #598 [finishes #81228592]
This commit is contained in:
slackersoft
2014-12-16 12:56:04 -08:00
parent eca8d8f009
commit 7570bc422b
6 changed files with 39 additions and 35 deletions
+3 -7
View File
@@ -31,7 +31,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
if (errorMatcher.hasNoSpecifics()) {
pass.message = 'Expected function not to throw an Error, but it threw ' + fnNameFor(thrown) + '.';
pass.message = 'Expected function not to throw an Error, but it threw ' + j$.fnNameFor(thrown) + '.';
return pass;
}
@@ -85,9 +85,9 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
return {
errorTypeDescription: errorType ? fnNameFor(errorType) : 'an exception',
errorTypeDescription: errorType ? j$.fnNameFor(errorType) : 'an exception',
thrownDescription: function(thrown) {
var thrownName = errorType ? fnNameFor(thrown.constructor) : 'an exception',
var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
thrownMessage = '';
if (expected) {
@@ -115,10 +115,6 @@ getJasmineRequireObj().toThrowError = function(j$) {
};
}
function fnNameFor(func) {
return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
}
function isStringOrRegExp(potential) {
return potential instanceof RegExp || (typeof potential == 'string');
}