Permalink
Browse files

[test] Add more tests for edge cases to forEachLimit

  • Loading branch information...
indexzero committed Jun 13, 2011
1 parent 90c80a1 commit 3753e4d452be6fb84bea312bf84b566bde27440c
Showing with 28 additions and 0 deletions.
  1. +28 −0 test/test-async.js
View
@@ -516,6 +516,34 @@ exports['forEachLimit empty array'] = function(test){
setTimeout(test.done, 25);
};
+exports['forEachLimit limit exceeds size'] = function(test){
+ var args = [];
+ var arr = [0,1,2,3,4,5,6,7,8,9];
+ async.forEachLimit(arr, 20, function(x,callback){
+ setTimeout(function(){
+ args.push(x);
+ callback();
+ }, x*5);
+ }, function(err){
+ test.same(args, arr);
+ test.done();
+ });
+};
+
+exports['forEachLimit limit equal size'] = function(test){
+ var args = [];
+ var arr = [0,1,2,3,4,5,6,7,8,9];
+ async.forEachLimit(arr, 10, function(x,callback){
+ setTimeout(function(){
+ args.push(x);
+ callback();
+ }, x*5);
+ }, function(err){
+ test.same(args, arr);
+ test.done();
+ });
+};
+
exports['forEachLimit zero limit'] = function(test){
test.expect(1);
async.forEachLimit([0,1,2,3,4,5], 0, function(x, callback){

0 comments on commit 3753e4d

Please sign in to comment.