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:
@@ -1,40 +1,45 @@
|
||||
jasmine.QueueRunner = function(attrs) {
|
||||
this.fns = attrs.fns || [];
|
||||
this.onComplete = attrs.onComplete || function() {};
|
||||
this.encourageGC = attrs.encourageGC || function(fn) {fn();};
|
||||
this.onException = attrs.onException || function() {};
|
||||
this.catchException = attrs.catchException || function() { return true; };
|
||||
};
|
||||
getJasmineRequireObj().QueueRunner = function() {
|
||||
|
||||
jasmine.QueueRunner.prototype.execute = function() {
|
||||
this.run(this.fns, 0);
|
||||
};
|
||||
|
||||
jasmine.QueueRunner.prototype.run = function(fns, index) {
|
||||
if (index >= fns.length) {
|
||||
this.encourageGC(this.onComplete);
|
||||
return;
|
||||
function QueueRunner(attrs) {
|
||||
this.fns = attrs.fns || [];
|
||||
this.onComplete = attrs.onComplete || function() {};
|
||||
this.encourageGC = attrs.encourageGC || function(fn) {fn();};
|
||||
this.onException = attrs.onException || function() {};
|
||||
this.catchException = attrs.catchException || function() { return true; };
|
||||
}
|
||||
|
||||
var fn = fns[index];
|
||||
var self = this;
|
||||
if (fn.length > 0) {
|
||||
attempt(function() { fn.call(self, function() { self.run(fns, index + 1); }); });
|
||||
} else {
|
||||
attempt(function() { fn.call(self); });
|
||||
self.run(fns, index + 1);
|
||||
}
|
||||
QueueRunner.prototype.execute = function() {
|
||||
this.run(this.fns, 0);
|
||||
};
|
||||
|
||||
function attempt(fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (e) {
|
||||
self.onException(e);
|
||||
if (!self.catchException(e)) {
|
||||
//TODO: set a var when we catch an exception and
|
||||
//use a finally block to close the loop in a nice way..
|
||||
throw e;
|
||||
QueueRunner.prototype.run = function(fns, index) {
|
||||
if (index >= fns.length) {
|
||||
this.encourageGC(this.onComplete);
|
||||
return;
|
||||
}
|
||||
|
||||
var fn = fns[index];
|
||||
var self = this;
|
||||
if (fn.length > 0) {
|
||||
attempt(function() { fn.call(self, function() { self.run(fns, index + 1); }); });
|
||||
} else {
|
||||
attempt(function() { fn.call(self); });
|
||||
self.run(fns, index + 1);
|
||||
}
|
||||
|
||||
function attempt(fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (e) {
|
||||
self.onException(e);
|
||||
if (!self.catchException(e)) {
|
||||
//TODO: set a var when we catch an exception and
|
||||
//use a finally block to close the loop in a nice way..
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return QueueRunner;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user