Skip to content

Commit

Permalink
Add short circuit test for every
Browse files Browse the repository at this point in the history
  • Loading branch information
megawac committed Oct 15, 2016
1 parent 509e3a7 commit 096e474
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mocha_test/every.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var async = require('../lib');
var expect = require('chai').expect;
var _ = require('lodash');

describe("every", function () {

Expand Down Expand Up @@ -83,6 +84,32 @@ describe("every", function () {
});
});

it('everySeries doesn\'t cause stack overflow (#1293)', function(done) {
var arr = _.range(10000);
let calls = 0;
async.everySeries(arr, function(data, cb) {
calls += 1;
async.setImmediate(_.partial(cb, null, false));
}, function(err) {
expect(err).to.equal(null);
expect(calls).to.equal(1);
done();
});
});

it('everyLimit doesn\'t cause stack overflow (#1293)', function(done) {
var arr = _.range(10000);
let calls = 0;
async.everyLimit(arr, 100, function(data, cb) {
calls += 1;
async.setImmediate(_.partial(cb, null, false));
}, function(err) {
expect(err).to.equal(null);
expect(calls).to.equal(100);
done();
});
});

it('all alias', function(){
expect(async.all).to.equal(async.every);
});
Expand Down

0 comments on commit 096e474

Please sign in to comment.