[Pkg-javascript-commits] [node-async] 72/480: added test for issue 10, make sure series and parallel return original falsy values instead of null

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:13 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 74b9dc2a6c149daa6ca09f63e327f2da8eafd329
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Tue Jan 18 09:55:41 2011 +0000

    added test for issue 10, make sure series and parallel return original falsy values instead of null
---
 lib/async.js       |  4 ++--
 test/test-async.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/lib/async.js b/lib/async.js
index 5314372..4fc4de6 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -423,7 +423,7 @@
                         if (args.length <= 1) {
                             args = args[0];
                         }
-                        callback.call(null, err, args || null);
+                        callback.call(null, err, args);
                     });
                 }
             }, callback);
@@ -455,7 +455,7 @@
                         if (args.length <= 1) {
                             args = args[0];
                         }
-                        callback.call(null, err, args || null);
+                        callback.call(null, err, args);
                     });
                 }
             }, callback);
diff --git a/test/test-async.js b/test/test-async.js
index 60b1d81..4dc57f9 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -1271,3 +1271,73 @@ exports['memoize custom hash function'] = function (test) {
     });
     test.done();
 };
+
+// Issue 10 on github: https://github.com/caolan/async/issues#issue/10
+exports['falsy return values in series'] = function (test) {
+    function taskFalse(callback) {
+        process.nextTick(function() {
+            callback(null, false);
+        });
+    };
+    function taskUndefined(callback) {
+        process.nextTick(function() {
+            callback(null, undefined);
+        });
+    };
+    function taskEmpty(callback) {
+        process.nextTick(function() {
+            callback(null);
+        });
+    };
+    function taskNull(callback) {
+        process.nextTick(function() {
+            callback(null, null);
+        });
+    };
+    async.series(
+        [taskFalse, taskUndefined, taskEmpty, taskNull],
+        function(err, results) {
+            test.same(results, [false, undefined, undefined, null]);
+            test.strictEqual(results[0], false);
+            test.strictEqual(results[1], undefined);
+            test.strictEqual(results[2], undefined);
+            test.strictEqual(results[3], null);
+            test.done();
+        }
+    );
+};
+
+// Issue 10 on github: https://github.com/caolan/async/issues#issue/10
+exports['falsy return values in parallel'] = function (test) {
+    function taskFalse(callback) {
+        process.nextTick(function() {
+            callback(null, false);
+        });
+    };
+    function taskUndefined(callback) {
+        process.nextTick(function() {
+            callback(null, undefined);
+        });
+    };
+    function taskEmpty(callback) {
+        process.nextTick(function() {
+            callback(null);
+        });
+    };
+    function taskNull(callback) {
+        process.nextTick(function() {
+            callback(null, null);
+        });
+    };
+    async.parallel(
+        [taskFalse, taskUndefined, taskEmpty, taskNull],
+        function(err, results) {
+            test.same(results, [false, undefined, undefined, null]);
+            test.strictEqual(results[0], false);
+            test.strictEqual(results[1], undefined);
+            test.strictEqual(results[2], undefined);
+            test.strictEqual(results[3], null);
+            test.done();
+        }
+    );
+};

-- 
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