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:
Davis W. Frank
2013-05-28 14:09:20 -07:00
parent 7516bba2b0
commit aca43bd3a3
52 changed files with 3828 additions and 3323 deletions

View File

@@ -1,144 +1,139 @@
var jasmine = {};
getJasmineRequireObj().base = function(j$) {
j$.unimplementedMethod_ = function() {
throw new Error("unimplemented method");
};
// TODO: do we need this now that we have boot.js?
if (typeof window == "undefined" && typeof exports == "object") {
exports.jasmine = jasmine;
}
j$.DEFAULT_UPDATE_INTERVAL = 250;
j$.MAX_PRETTY_PRINT_DEPTH = 40;
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
jasmine.unimplementedMethod_ = function() {
throw new Error("unimplemented method");
};
j$.getGlobal = function() {
function getGlobal() {
return this;
}
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
return getGlobal();
};
jasmine.getGlobal = function() {
function getGlobal() {
j$.getEnv = function(options) {
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
//jasmine. singletons in here (setTimeout blah blah).
return env;
};
j$.isArray_ = function(value) {
return j$.isA_("Array", value);
};
j$.isString_ = function(value) {
return j$.isA_("String", value);
};
j$.isNumber_ = function(value) {
return j$.isA_("Number", value);
};
j$.isA_ = function(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
};
j$.pp = function(value) {
var stringPrettyPrinter = new j$.StringPrettyPrinter();
stringPrettyPrinter.format(value);
return stringPrettyPrinter.string;
};
j$.isDomNode = function(obj) {
return obj.nodeType > 0;
};
j$.any = function(clazz) {
return new j$.Matchers.Any(clazz);
};
j$.objectContaining = function(sample) {
return new j$.Matchers.ObjectContaining(sample);
};
j$.Spy = function(name) {
this.identity = name || 'unknown';
this.isSpy = true;
this.plan = function() {
};
this.mostRecentCall = {};
this.argsForCall = [];
this.calls = [];
};
j$.Spy.prototype.andCallThrough = function() {
this.plan = this.originalValue;
return this;
}
return getGlobal();
};
jasmine.getEnv = function(options) {
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(options);
//jasmine. singletons in here (setTimeout blah blah).
return env;
};
jasmine.isArray_ = function(value) {
return jasmine.isA_("Array", value);
};
jasmine.isString_ = function(value) {
return jasmine.isA_("String", value);
};
jasmine.isNumber_ = function(value) {
return jasmine.isA_("Number", value);
};
jasmine.isA_ = function(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
};
jasmine.pp = function(value) {
var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
stringPrettyPrinter.format(value);
return stringPrettyPrinter.string;
};
jasmine.isDomNode = function(obj) {
return obj.nodeType > 0;
};
jasmine.any = function(clazz) {
return new jasmine.Matchers.Any(clazz);
};
jasmine.objectContaining = function (sample) {
return new jasmine.Matchers.ObjectContaining(sample);
};
jasmine.Spy = function(name) {
this.identity = name || 'unknown';
this.isSpy = true;
this.plan = function() {
};
this.mostRecentCall = {};
this.argsForCall = [];
this.calls = [];
};
jasmine.Spy.prototype.andCallThrough = function() {
this.plan = this.originalValue;
return this;
};
jasmine.Spy.prototype.andReturn = function(value) {
this.plan = function() {
return value;
};
return this;
};
jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
this.plan = function() {
throw exceptionMsg;
};
return this;
};
jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
this.plan = fakeFunc;
return this;
};
jasmine.Spy.prototype.reset = function() {
this.wasCalled = false;
this.callCount = 0;
this.argsForCall = [];
this.calls = [];
this.mostRecentCall = {};
};
jasmine.createSpy = function(name) {
var spyObj = function() {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = jasmine.util.argsToArray(arguments);
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
spyObj.calls.push({object: this, args: args});
return spyObj.plan.apply(this, arguments);
};
var spy = new jasmine.Spy(name);
j$.Spy.prototype.andReturn = function(value) {
this.plan = function() {
return value;
};
return this;
};
for (var prop in spy) {
spyObj[prop] = spy[prop];
}
j$.Spy.prototype.andThrow = function(exceptionMsg) {
this.plan = function() {
throw exceptionMsg;
};
return this;
};
spyObj.reset();
j$.Spy.prototype.andCallFake = function(fakeFunc) {
this.plan = fakeFunc;
return this;
};
return spyObj;
};
jasmine.isSpy = function(putativeSpy) {
return putativeSpy && putativeSpy.isSpy;
};
jasmine.createSpyObj = function(baseName, methodNames) {
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
}
var obj = {};
for (var i = 0; i < methodNames.length; i++) {
obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
}
return obj;
j$.Spy.prototype.reset = function() {
this.wasCalled = false;
this.callCount = 0;
this.argsForCall = [];
this.calls = [];
this.mostRecentCall = {};
};
j$.createSpy = function(name) {
var spyObj = function() {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = j$.util.argsToArray(arguments);
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
spyObj.calls.push({object: this, args: args});
return spyObj.plan.apply(this, arguments);
};
var spy = new j$.Spy(name);
for (var prop in spy) {
spyObj[prop] = spy[prop];
}
spyObj.reset();
return spyObj;
};
j$.isSpy = function(putativeSpy) {
return putativeSpy && putativeSpy.isSpy;
};
j$.createSpyObj = function(baseName, methodNames) {
if (!j$.isArray_(methodNames) || methodNames.length === 0) {
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
}
var obj = {};
for (var i = 0; i < methodNames.length; i++) {
obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
}
return obj;
};
};