Prettyprint objects whose constructors have custom toString method
- when the constructor has a name, print the name - when the constructor does not have a name, print `<anonymous>` [Fixes issue 1019](https://github.com/jasmine/jasmine/issues/1019)
This commit is contained in:
@@ -38,7 +38,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
j$.fnNameFor = function(func) {
|
||||
return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
|
||||
if (func.name) {
|
||||
return func.name;
|
||||
}
|
||||
|
||||
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
|
||||
return matches ? matches[1] : '<anonymous>';
|
||||
};
|
||||
|
||||
j$.any = function(clazz) {
|
||||
|
||||
Reference in New Issue
Block a user