diff options
author | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-02 13:36:16 -0400 |
---|---|---|
committer | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-02 13:36:16 -0400 |
commit | 529cd5ccb3b5ad4901d725602ab47bc96e847b12 (patch) | |
tree | 7873fafc804c940a82e0837f9291096ea54e5709 /test | |
parent | 3c900be947697d00eb6fdb0f57c205825a652a5a (diff) | |
download | async-529cd5ccb3b5ad4901d725602ab47bc96e847b12.tar.gz |
Test short circuiting of every* and some*
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-async.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test-async.js b/test/test-async.js index b7847bf..07b72e7 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(); |