small QueueRunner refactors
This commit is contained in:
@@ -280,7 +280,11 @@ getJasmineRequireObj().Spec = function() {
|
|||||||
|
|
||||||
this.queueRunner({
|
this.queueRunner({
|
||||||
fns: allFns,
|
fns: allFns,
|
||||||
onException: function(e) {
|
onException: onException,
|
||||||
|
onComplete: complete
|
||||||
|
});
|
||||||
|
|
||||||
|
function onException(e) {
|
||||||
if (Spec.isPendingSpecException(e)) {
|
if (Spec.isPendingSpecException(e)) {
|
||||||
self.pend();
|
self.pend();
|
||||||
return;
|
return;
|
||||||
@@ -293,9 +297,7 @@ getJasmineRequireObj().Spec = function() {
|
|||||||
actual: "",
|
actual: "",
|
||||||
error: e
|
error: e
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
onComplete: complete
|
|
||||||
});
|
|
||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
self.result.status = self.status();
|
self.result.status = self.status();
|
||||||
@@ -1424,15 +1426,9 @@ getJasmineRequireObj().QueueRunner = function() {
|
|||||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||||
var fn = fns[iterativeIndex];
|
var fn = fns[iterativeIndex];
|
||||||
if (fn.length > 0) {
|
if (fn.length > 0) {
|
||||||
var attemptSuccessful = attempt(function() {
|
return attemptAsync(fn);
|
||||||
fn.call(self, function() { self.run(fns, iterativeIndex + 1); });
|
|
||||||
});
|
|
||||||
|
|
||||||
if(attemptSuccessful) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
attempt(function() { fn.call(self); });
|
attemptSync(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1442,19 +1438,32 @@ getJasmineRequireObj().QueueRunner = function() {
|
|||||||
this.clearStack(this.onComplete);
|
this.clearStack(this.onComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
function attempt(fn) {
|
function attemptSync(fn) {
|
||||||
try {
|
try {
|
||||||
fn();
|
fn.call(self);
|
||||||
return true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
handleException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function attemptAsync(fn) {
|
||||||
|
var next = function () { self.run(fns, iterativeIndex + 1); };
|
||||||
|
|
||||||
|
try {
|
||||||
|
fn.call(self, next);
|
||||||
|
} catch (e) {
|
||||||
|
handleException(e);
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleException(e) {
|
||||||
self.onException(e);
|
self.onException(e);
|
||||||
if (!self.catchException(e)) {
|
if (!self.catchException(e)) {
|
||||||
//TODO: set a var when we catch an exception and
|
//TODO: set a var when we catch an exception and
|
||||||
//use a finally block to close the loop in a nice way..
|
//use a finally block to close the loop in a nice way..
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,9 @@ getJasmineRequireObj().QueueRunner = function() {
|
|||||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||||
var fn = fns[iterativeIndex];
|
var fn = fns[iterativeIndex];
|
||||||
if (fn.length > 0) {
|
if (fn.length > 0) {
|
||||||
var attemptSuccessful = attempt(function() {
|
return attemptAsync(fn);
|
||||||
fn.call(self, function() { self.run(fns, iterativeIndex + 1); });
|
|
||||||
});
|
|
||||||
|
|
||||||
if(attemptSuccessful) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
attempt(function() { fn.call(self); });
|
attemptSync(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,19 +32,32 @@ getJasmineRequireObj().QueueRunner = function() {
|
|||||||
this.clearStack(this.onComplete);
|
this.clearStack(this.onComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
function attempt(fn) {
|
function attemptSync(fn) {
|
||||||
try {
|
try {
|
||||||
fn();
|
fn.call(self);
|
||||||
return true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
handleException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function attemptAsync(fn) {
|
||||||
|
var next = function () { self.run(fns, iterativeIndex + 1); };
|
||||||
|
|
||||||
|
try {
|
||||||
|
fn.call(self, next);
|
||||||
|
} catch (e) {
|
||||||
|
handleException(e);
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleException(e) {
|
||||||
self.onException(e);
|
self.onException(e);
|
||||||
if (!self.catchException(e)) {
|
if (!self.catchException(e)) {
|
||||||
//TODO: set a var when we catch an exception and
|
//TODO: set a var when we catch an exception and
|
||||||
//use a finally block to close the loop in a nice way..
|
//use a finally block to close the loop in a nice way..
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,11 @@ getJasmineRequireObj().Spec = function() {
|
|||||||
|
|
||||||
this.queueRunner({
|
this.queueRunner({
|
||||||
fns: allFns,
|
fns: allFns,
|
||||||
onException: function(e) {
|
onException: onException,
|
||||||
|
onComplete: complete
|
||||||
|
});
|
||||||
|
|
||||||
|
function onException(e) {
|
||||||
if (Spec.isPendingSpecException(e)) {
|
if (Spec.isPendingSpecException(e)) {
|
||||||
self.pend();
|
self.pend();
|
||||||
return;
|
return;
|
||||||
@@ -70,9 +74,7 @@ getJasmineRequireObj().Spec = function() {
|
|||||||
actual: "",
|
actual: "",
|
||||||
error: e
|
error: e
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
onComplete: complete
|
|
||||||
});
|
|
||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
self.result.status = self.status();
|
self.result.status = self.status();
|
||||||
|
|||||||
Reference in New Issue
Block a user