[Pkg-javascript-commits] [node-async] 274/480: fixed queue bug, added test

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 13a9abf61d8a9696ac7f9b77451a7c98f9b18882
Author: zaphod1984 <zaphod84 at gmx.de>
Date:   Wed Feb 6 10:28:30 2013 +0100

    fixed queue bug, added test
---
 lib/async.js       |  7 ++++---
 test/test-async.js | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/lib/async.js b/lib/async.js
old mode 100644
new mode 100755
index 2247d0e..5f2fb18
--- a/lib/async.js
+++ b/lib/async.js
@@ -745,12 +745,13 @@
                         q.process();
                     };
                     var cb = only_once(function () {
+                        var cbArgs = arguments;
+
                         if (sync) {
                             async.nextTick(function () {
-                                next.apply(null, arguments);
+                                next.apply(null, cbArgs);
                             });
-                        }
-                        else {
+                        } else {
                             next.apply(null, arguments);
                         }
                     });
diff --git a/test/test-async.js b/test/test-async.js
old mode 100644
new mode 100755
index fafa6d7..323527a
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -1587,6 +1587,37 @@ exports['queue'] = function (test) {
     };
 };
 
+exports['queue error propagation'] = function(test){
+    var results = [];
+
+    var q = async.queue(function (task, callback) {
+        callback(task.name === 'foo' ? new Error('fooError') : null);
+    }, 2);
+
+    q.drain = function() {
+        test.deepEqual(results, ['bar', 'fooError']);
+        test.done();
+    };
+
+    q.push({name: 'bar'}, function (err) {
+        if(err) {
+            results.push('barError');
+            return;
+        }
+
+        results.push('bar');
+    });
+
+    q.push({name: 'foo'}, function (err) {
+        if(err) {
+            results.push('fooError');
+            return;
+        }
+
+        results.push('foo');
+    });
+};
+
 exports['queue changing concurrency'] = function (test) {
     var call_order = [],
         delays = [40,20,60,20];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list