Rename for stack-clearing post spec run to be more clear; use the real setTimeout when clearing stack
This commit is contained in:
@@ -7,6 +7,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
var catchExceptions = true;
|
||||
|
||||
var realSetTimeout = global.setTimeout;
|
||||
this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler());
|
||||
|
||||
this.spies_ = [];
|
||||
@@ -108,11 +109,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
var maximumSpecCallbackDepth = 100;
|
||||
var currentSpecCallbackDepth = 0;
|
||||
|
||||
function encourageGarbageCollection(fn) {
|
||||
function clearStack(fn) {
|
||||
currentSpecCallbackDepth++;
|
||||
if (currentSpecCallbackDepth > maximumSpecCallbackDepth) {
|
||||
currentSpecCallbackDepth = 0;
|
||||
global.setTimeout(fn, 0);
|
||||
realSetTimeout(fn, 0);
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
@@ -120,7 +121,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
var queueRunnerFactory = function(options) {
|
||||
options.catchException = self.catchException;
|
||||
options.encourageGC = options.encourageGarbageCollection || encourageGarbageCollection;
|
||||
options.clearStack = options.clearStack || clearStack;
|
||||
|
||||
new j$.QueueRunner(options).run(options.fns, 0);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
function QueueRunner(attrs) {
|
||||
this.fns = attrs.fns || [];
|
||||
this.onComplete = attrs.onComplete || function() {};
|
||||
this.encourageGC = attrs.encourageGC || function(fn) {fn();};
|
||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||
this.onException = attrs.onException || function() {};
|
||||
this.catchException = attrs.catchException || function() { return true; };
|
||||
}
|
||||
@@ -14,7 +14,7 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
|
||||
QueueRunner.prototype.run = function(fns, index) {
|
||||
if (index >= fns.length) {
|
||||
this.encourageGC(this.onComplete);
|
||||
this.clearStack(this.onComplete);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ getJasmineRequireObj().Suite = function() {
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.completeCallback = attrs.completeCallback || function() {};
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.encourageGC = attrs.encourageGC || function(fn) {fn();};
|
||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||
|
||||
this.beforeFns = [];
|
||||
this.afterFns = [];
|
||||
|
||||
Reference in New Issue
Block a user