Consistent use of callCount variable.

This commit is contained in:
jdalton
2015-02-23 08:20:23 -08:00
parent 5613f60403
commit 6840b2cfe5

View File

@@ -3212,17 +3212,17 @@
(function() { (function() {
asyncTest('should debounce a function', 2, function() { asyncTest('should debounce a function', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
debounced = _.debounce(function() { count++; }, 32); debounced = _.debounce(function() { callCount++; }, 32);
debounced(); debounced();
debounced(); debounced();
debounced(); debounced();
strictEqual(count, 0); strictEqual(callCount, 0);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 96); }, 96);
} }
@@ -3273,17 +3273,17 @@
asyncTest('should apply default options correctly', 2, function() { asyncTest('should apply default options correctly', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
count++; callCount++;
return value; return value;
}, 32, {}); }, 32, {});
strictEqual(debounced('x'), undefined); strictEqual(debounced('x'), undefined);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -3296,11 +3296,11 @@
asyncTest('should support a `leading` option', 7, function() { asyncTest('should support a `leading` option', 7, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var withLeading, var withLeading,
counts = [0, 0, 0]; callCounts = [0, 0, 0];
_.each([true, { 'leading': true }], function(options, index) { _.each([true, { 'leading': true }], function(options, index) {
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
counts[index]++; callCounts[index]++;
return value; return value;
}, 32, options); }, 32, options);
@@ -3316,19 +3316,19 @@
}); });
var withLeadingAndTrailing = _.debounce(function() { var withLeadingAndTrailing = _.debounce(function() {
counts[2]++; callCounts[2]++;
}, 32, { 'leading': true }); }, 32, { 'leading': true });
withLeadingAndTrailing(); withLeadingAndTrailing();
withLeadingAndTrailing(); withLeadingAndTrailing();
strictEqual(counts[2], 1); strictEqual(callCounts[2], 1);
setTimeout(function() { setTimeout(function() {
deepEqual(counts, [1, 1, 2]); deepEqual(callCounts, [1, 1, 2]);
withLeading('x'); withLeading('x');
strictEqual(counts[1], 2); strictEqual(callCounts[1], 2);
QUnit.start(); QUnit.start();
}, 64); }, 64);
@@ -3403,16 +3403,16 @@
asyncTest('should cancel `maxDelayed` when `delayed` is invoked', 1, function() { asyncTest('should cancel `maxDelayed` when `delayed` is invoked', 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var debounced = _.debounce(function() { var debounced = _.debounce(function() {
count++; callCount++;
}, 32, { 'maxWait': 64 }); }, 32, { 'maxWait': 64 });
debounced(); debounced();
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 128); }, 128);
} }
@@ -3425,13 +3425,13 @@
asyncTest('should invoke the `trailing` call with the correct arguments and `this` binding', 2, function() { asyncTest('should invoke the `trailing` call with the correct arguments and `this` binding', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var actual, var actual,
count = 0, callCount = 0,
object = {}; object = {};
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
actual = [this]; actual = [this];
push.apply(actual, arguments); push.apply(actual, arguments);
return ++count != 2; return ++callCount != 2;
}, 32, { 'leading': true, 'maxWait': 64 }); }, 32, { 'leading': true, 'maxWait': 64 });
while (true) { while (true) {
@@ -3440,7 +3440,7 @@
} }
} }
setTimeout(function() { setTimeout(function() {
strictEqual(count, 2); strictEqual(callCount, 2);
deepEqual(actual, [object, 'a']); deepEqual(actual, [object, 'a']);
QUnit.start(); QUnit.start();
}, 64); }, 64);
@@ -13638,18 +13638,18 @@
(function() { (function() {
asyncTest('should throttle a function', 2, function() { asyncTest('should throttle a function', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0,
var throttled = _.throttle(function() { count++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
throttled(); throttled();
throttled(); throttled();
throttled(); throttled();
var lastCount = count; var lastCount = callCount;
ok(count > 0); ok(callCount > 0);
setTimeout(function() { setTimeout(function() {
ok(count > lastCount); ok(callCount > lastCount);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -13718,14 +13718,14 @@
asyncTest('should not trigger a trailing call when invoked once', 2, function() { asyncTest('should not trigger a trailing call when invoked once', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
throttled = _.throttle(function() { count++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
throttled(); throttled();
strictEqual(count, 1); strictEqual(callCount, 1);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -13738,19 +13738,19 @@
_.times(2, function(index) { _.times(2, function(index) {
asyncTest('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), 1, function() { asyncTest('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
limit = (argv || isPhantom) ? 1000 : 320, limit = (argv || isPhantom) ? 1000 : 320,
options = index ? { 'leading': false } : {}; options = index ? { 'leading': false } : {};
var throttled = _.throttle(function() { var throttled = _.throttle(function() {
count++; callCount++;
}, 32, options); }, 32, options);
var start = +new Date; var start = +new Date;
while ((new Date - start) < limit) { while ((new Date - start) < limit) {
throttled(); throttled();
} }
var actual = count > 1; var actual = callCount > 1;
setTimeout(function() { setTimeout(function() {
ok(actual); ok(actual);
@@ -13766,10 +13766,10 @@
asyncTest('should apply default options correctly', 3, function() { asyncTest('should apply default options correctly', 3, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var throttled = _.throttle(function(value) { var throttled = _.throttle(function(value) {
count++; callCount++;
return value; return value;
}, 32, {}); }, 32, {});
@@ -13777,7 +13777,7 @@
strictEqual(throttled('b'), 'a'); strictEqual(throttled('b'), 'a');
setTimeout(function() { setTimeout(function() {
strictEqual(count, 2); strictEqual(callCount, 2);
QUnit.start(); QUnit.start();
}, 256); }, 256);
} }
@@ -13844,10 +13844,10 @@
asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', 1, function() { asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var throttled = _.throttle(function() { var throttled = _.throttle(function() {
count++; callCount++;
}, 64, { 'trailing': false }); }, 64, { 'trailing': false });
throttled(); throttled();
@@ -13859,7 +13859,7 @@
}, 96); }, 96);
setTimeout(function() { setTimeout(function() {
ok(count > 1); ok(callCount > 1);
QUnit.start(); QUnit.start();
}, 192); }, 192);
} }