51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
|
/** @namespace */
|
||
|
jasmine.util = {};
|
||
|
|
||
|
jasmine.util.inherit = function(childClass, parentClass) {
|
||
|
var subclass = function() {
|
||
|
};
|
||
|
subclass.prototype = parentClass.prototype;
|
||
|
childClass.prototype = new subclass;
|
||
|
};
|
||
|
|
||
|
jasmine.util.formatException = function(e) {
|
||
|
var lineNumber;
|
||
|
if (e.line) {
|
||
|
lineNumber = e.line;
|
||
|
}
|
||
|
else if (e.lineNumber) {
|
||
|
lineNumber = e.lineNumber;
|
||
|
}
|
||
|
|
||
|
var file;
|
||
|
|
||
|
if (e.sourceURL) {
|
||
|
file = e.sourceURL;
|
||
|
}
|
||
|
else if (e.fileName) {
|
||
|
file = e.fileName;
|
||
|
}
|
||
|
|
||
|
var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
|
||
|
|
||
|
if (file && lineNumber) {
|
||
|
message += ' in ' + file + ' (line ' + lineNumber + ')';
|
||
|
}
|
||
|
|
||
|
return message;
|
||
|
};
|
||
|
|
||
|
jasmine.util.htmlEscape = function(str) {
|
||
|
if (!str) return str;
|
||
|
return str.replace(/&/g, '&')
|
||
|
.replace(/</g, '<')
|
||
|
.replace(/>/g, '>');
|
||
|
};
|
||
|
|
||
|
jasmine.util.argsToArray = function(args) {
|
||
|
var arrayOfArgs = [];
|
||
|
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
|
||
|
return arrayOfArgs;
|
||
|
};
|
||
|
|