Skip to content

Commit

Permalink
test(detect): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
suguru03 committed Oct 16, 2016
1 parent 54ce156 commit 07cb01a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/collections/test.detect.js
Expand Up @@ -766,6 +766,24 @@ parallel('#detectSeries', function() {
});
});

it('should not cause stack overflow', function(done) {

var array = _.range(10000);
var calls = 0;
async.detectSeries(array, function(data, callback) {
calls++;
setImmediate(function() {
callback(null, true);
});
}, function(err) {
if (err) {
return done(err);
}
assert.strictEqual(calls, 1);
done();
});
});

});

parallel('#detectLimit', function() {
Expand Down Expand Up @@ -1207,4 +1225,22 @@ parallel('#detectLimit', function() {
}, 10 * delay);
});

it('should not cause stack overflow', function(done) {

var array = _.range(10000);
var calls = 0;
async.detectLimit(array, 100, function(data, callback) {
calls++;
setImmediate(function() {
callback(null, true);
});
}, function(err) {
if (err) {
return done(err);
}
assert.strictEqual(calls, 100);
done();
});
});

});

0 comments on commit 07cb01a

Please sign in to comment.