summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane MBAPE <smbape@yahoo.fr>2018-02-15 08:20:45 +0100
committerStéphane MBAPE <smbape@yahoo.fr>2018-02-15 08:20:45 +0100
commit402733d8ebdab047090527cbc9e153e26eaeee8d (patch)
tree282a270785176abedc31d82beedb71edc7cfa6f0
parentcd6beba687bec8112357ff72b6a610cf245590cd (diff)
downloadasync-402733d8ebdab047090527cbc9e153e26eaeee8d.tar.gz
rename 'forEachOfLimit 1024 * 1024 synchronous call' to 'forEachOfLimit no call stack size exceed error'
done called inside of the final callback of 'forEachOfLimit no call stack size exceed error' added 'forEachOf no call stack size exceed error' and 'forEachOfSeries no call stack size exceed error' tests
-rw-r--r--mocha_test/eachOf.js52
1 files changed, 50 insertions, 2 deletions
diff --git a/mocha_test/eachOf.js b/mocha_test/eachOf.js
index a6c6864..dd73c22 100644
--- a/mocha_test/eachOf.js
+++ b/mocha_test/eachOf.js
@@ -43,6 +43,30 @@ describe("eachOf", function() {
});
});
+ it('forEachOf no call stack size exceed error', function(done) {
+ var obj = {};
+ var len = 3000;
+ var args = new Array(len * 2);
+ var expected = new Array(len * 2);
+
+ for (var i = 0; i < len; i++) {
+ obj["a" + i] = i;
+ expected[2 * i] = "a" + i;
+ expected[2 * i + 1] = i;
+ }
+
+ async.forEachOf(obj, function(value, key, callback) {
+ var index = parseInt(key.slice(1), 10);
+ args[2 * index] = key;
+ args[2 * index + 1] = value;
+ callback();
+ }, function(err) {
+ assert(err === null, err + " passed instead of 'null'");
+ expect(args).to.eql(expected);
+ done();
+ });
+ });
+
it('forEachOf - instant resolver', function(done) {
var args = [];
async.forEachOf({ a: 1, b: 2 }, function(x, k, cb) {
@@ -139,6 +163,30 @@ describe("eachOf", function() {
});
});
+ it('forEachOfSeries no call stack size exceed error', function(done) {
+ var obj = {};
+ var len = 3000;
+ var args = new Array(len * 2);
+ var expected = new Array(len * 2);
+
+ for (var i = 0; i < len; i++) {
+ obj["a" + i] = i;
+ expected[2 * i] = "a" + i;
+ expected[2 * i + 1] = i;
+ }
+
+ async.forEachOfSeries(obj, function(value, key, callback) {
+ var index = parseInt(key.slice(1), 10);
+ args[2 * index] = key;
+ args[2 * index + 1] = value;
+ callback();
+ }, function(err) {
+ assert(err === null, err + " passed instead of 'null'");
+ expect(args).to.eql(expected);
+ done();
+ });
+ });
+
it('forEachOfSeries empty object', function(done) {
async.forEachOfSeries({}, function(x, callback){
assert(false, 'iteratee should not be called');
@@ -274,7 +322,7 @@ describe("eachOf", function() {
setTimeout(done, 25);
});
- it('forEachOfLimit 1024 * 1024 synchronous call', function(done) {
+ it('forEachOfLimit no call stack size exceed error', function(done) {
var count = 0;
async.forEachOfLimit(_.range(1024 * 1024), Infinity, function(x, i, callback){
count++;
@@ -282,8 +330,8 @@ describe("eachOf", function() {
}, function(err){
if (err) throw err;
expect(count).to.equal(1024 * 1024);
+ done();
});
- setTimeout(done, 25);
});
it('forEachOfLimit error', function(done) {