Rename for stack-clearing post spec run to be more clear; use the real setTimeout when clearing stack

This commit is contained in:
Davis W. Frank and Sheel Choksi
2013-07-02 09:51:41 -07:00
parent 2916a8a1ff
commit f5bc9faf63
5 changed files with 17 additions and 15 deletions

View File

@@ -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);
};