Squashed commit of work to make Jasmine a collection of isolated modules. Note now that in our test suite, "jasmine" now always refers to the build jasmine loaded from jasmine.js and "j$" always refers to the code in the src directories.
Also, dev_boot.js is now a copy of boot.js and has additional changes to load jasmine the second time, into the j$ reference.
This commit is contained in:
103
src/core/util.js
103
src/core/util.js
@@ -1,52 +1,57 @@
|
||||
jasmine.util = {};
|
||||
getJasmineRequireObj().util = function() {
|
||||
|
||||
jasmine.util.inherit = function(childClass, parentClass) {
|
||||
var subclass = function() {
|
||||
var util = {};
|
||||
|
||||
util.inherit = function(childClass, parentClass) {
|
||||
var subclass = function() {
|
||||
};
|
||||
subclass.prototype = parentClass.prototype;
|
||||
childClass.prototype = new subclass();
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
jasmine.util.isUndefined = function(obj) {
|
||||
return obj === void 0;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
util.htmlEscape = function(str) {
|
||||
if (!str) return str;
|
||||
return str.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
};
|
||||
|
||||
util.argsToArray = function(args) {
|
||||
var arrayOfArgs = [];
|
||||
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
|
||||
return arrayOfArgs;
|
||||
};
|
||||
|
||||
util.isUndefined = function(obj) {
|
||||
return obj === void 0;
|
||||
};
|
||||
|
||||
return util;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user