summaryrefslogtreecommitdiff
path: root/test/test-async.js
diff options
context:
space:
mode:
authorCaolan McMahon <caolan@caolanmcmahon.com>2013-03-15 12:37:31 +0000
committerCaolan McMahon <caolan@caolanmcmahon.com>2013-03-15 12:37:31 +0000
commita0d565d01bd256ea3d67104925139576d110aadb (patch)
tree4b3083deccfe18a2cbe45e7c0de74165d6da1a09 /test/test-async.js
parent82e638c909d4effb4108665918d771d08e9d8b9e (diff)
downloadasync-a0d565d01bd256ea3d67104925139576d110aadb.tar.gz
revert detection of sync tasks and add setImmediate
Diffstat (limited to 'test/test-async.js')
-rwxr-xr-xtest/test-async.js57
1 files changed, 1 insertions, 56 deletions
diff --git a/test/test-async.js b/test/test-async.js
index 5bd72bf..cba6f4b 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2341,7 +2341,7 @@ exports['queue events'] = function(test) {
var q = async.queue(function(task, cb) {
// nop
calls.push('process ' + task);
- cb();
+ async.setImmediate(cb);
}, 3);
q.saturated = function() {
@@ -2381,58 +2381,3 @@ exports['queue events'] = function(test) {
q.push('poo', function () {calls.push('poo cb');});
q.push('moo', function () {calls.push('moo cb');});
};
-
-exports['avoid stack overflows for sync tasks'] = function (test) {
- if (typeof window !== 'undefined') {
- // skip this test in the browser, it takes AGES
- return test.done();
- }
- var arr = [];
- var funcarr = [];
- for (var i = 0; i < 10000; i++) {
- arr.push[i];
- funcarr.push(function (cb) { return cb(); });
- }
- var iter = function (i, cb) { cb(); };
- var counter = 0;
- var pred1 = function () {
- return counter <= 10000;
- };
- var iter = function (cb) {
- counter++;
- cb();
- };
- var pred2 = function () {
- return counter > 10000;
- };
- var resetCounter = function (cb) {
- counter = 0;
- cb();
- }
- async.series([
- async.apply(async.each, arr, iter),
- async.apply(async.eachSeries, arr, iter),
- async.apply(async.eachLimit, arr, iter, 2),
- async.apply(async.whilst, pred1, iter),
- resetCounter,
- async.apply(async.until, pred2, iter),
- resetCounter,
- async.apply(async.doWhilst, iter, pred1),
- resetCounter,
- async.apply(async.doUntil, iter, pred2),
- async.apply(async.series, funcarr),
- async.apply(async.parallel, funcarr),
- function (callback) {
- var q = async.queue(function (task, cb) {
- cb();
- }, 2);
- for (var j = 0; j < 10000; j++) {
- q.push(j);
- }
- q.drain = callback;
- }
- ],
- function (err) {
- test.done(err);
- });
-};