From 529cd5ccb3b5ad4901d725602ab47bc96e847b12 Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Thu, 2 Jul 2015 13:36:16 -0400 Subject: [PATCH] Test short circuiting of every* and some* --- test/test-async.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/test-async.js b/test/test-async.js index b7847bf14..07b72e7c6 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -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();