[Pkg-javascript-commits] [node-async] 365/480: Refactor memoize test to use async function

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:42 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 be4e7ef193e68e1e78fa95c0b2922a38d24485bb
Author: Ryan Graham <r.m.graham at gmail.com>
Date:   Sat Nov 23 22:18:50 2013 -0800

    Refactor memoize test to use async function
    
    Makes example async function async by using async.setImmediate
---
 test/test-async.js | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/test/test-async.js b/test/test-async.js
index b7c767b..17e6fc5 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2200,23 +2200,24 @@ exports['memoize'] = function (test) {
     var call_order = [];
 
     var fn = function (arg1, arg2, callback) {
-        call_order.push(['fn', arg1, arg2]);
-        callback(null, arg1 + arg2);
+        async.setImmediate(function () {
+            call_order.push(['fn', arg1, arg2]);
+            callback(null, arg1 + arg2);
+        });
     };
 
     var fn2 = async.memoize(fn);
     fn2(1, 2, function (err, result) {
         test.equal(result, 3);
+        fn2(1, 2, function (err, result) {
+            test.equal(result, 3);
+            fn2(2, 2, function (err, result) {
+                test.equal(result, 4);
+                test.same(call_order, [['fn',1,2], ['fn',2,2]]);
+                test.done();
+            });
+        });
     });
-    fn2(1, 2, function (err, result) {
-        test.equal(result, 3);
-    });
-    fn2(2, 2, function (err, result) {
-        test.equal(result, 4);
-    });
-
-    test.same(call_order, [['fn',1,2], ['fn',2,2]]);
-    test.done();
 };
 
 exports['memoize maintains asynchrony'] = function (test) {

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