Skip to content

Commit

Permalink
When we use the real setTimeout in TestCase, also use the real clearT…
Browse files Browse the repository at this point in the history
…imeout.
  • Loading branch information
jcoglan committed Oct 18, 2015
1 parent afaf1ff commit 0e2b551
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions source/test/unit/test_case.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ Test.Unit.extend({
? methodName.length
: this.__eigen__().instanceMethod(methodName).arity,

callable = (typeof methodName === 'function') ? methodName : this[methodName],
timeout = null,
failed = false,
resumed = false,
self = this;
callable = (typeof methodName === 'function') ? methodName : this[methodName],
setTimeout = Test.FakeClock.REAL.setTimeout,
clearTimeout = Test.FakeClock.REAL.clearTimeout,
timeout = null,
failed = false,
resumed = false,
self = this;

if (arity === 0)
return this.klass.runWithExceptionHandlers(this, function() {
Expand All @@ -184,7 +186,7 @@ Test.Unit.extend({
var onUncaughtError = function(error) {
failed = true;
self.klass.popErrorCathcer();
if (timeout) JS.ENV.clearTimeout(timeout);
if (timeout) clearTimeout(timeout);
onError.call(self, error);
};
this.klass.pushErrorCathcer(onUncaughtError);
Expand All @@ -193,7 +195,7 @@ Test.Unit.extend({
callable.call(this, function(asyncResult) {
resumed = true;
self.klass.popErrorCathcer();
if (timeout) JS.ENV.clearTimeout(timeout);
if (timeout) clearTimeout(timeout);
if (failed) return;

if (typeof asyncResult === 'string') asyncResult = new Error(asyncResult);
Expand All @@ -208,7 +210,6 @@ Test.Unit.extend({
}, onError);

if (resumed || !JS.ENV.setTimeout) return;
var setTimeout = Test.FakeClock.REAL.setTimeout;

timeout = setTimeout(function() {
failed = true;
Expand Down

0 comments on commit 0e2b551

Please sign in to comment.