Skip to content

Commit

Permalink
Test short circuiting of every* and some*
Browse files Browse the repository at this point in the history
  • Loading branch information
megawac committed Jul 2, 2015
1 parent 3c900be commit 529cd5c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,33 @@ exports['everyLimit false'] = function(test){
});
};

exports['everyLimit short-circuit'] = function(test){
test.expect(2);
var calls = 0;
async.everyLimit([3,1,2], 1, function(x, callback){
calls++;
callback(x === 1);
}, function(result){
test.equals(result, false);
test.equals(calls, 1);
test.done();
});
};


exports['someLimit short-circuit'] = function(test){
test.expect(2);
var calls = 0;
async.someLimit([3,1,2], 1, function(x, callback){
calls++;
callback(x === 1);
}, function(result){
test.equals(result, true);
test.equals(calls, 2);
test.done();
});
};

exports['any alias'] = function(test){
test.equals(async.any, async.some);
test.done();
Expand Down

0 comments on commit 529cd5c

Please sign in to comment.