[Pkg-javascript-commits] [node-async] 363/480: Add invalid passing async.memoize() test
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 0bdb2216c4762a5eeb4527fb3b3c063287943e84
Author: Ryan Graham <r.m.graham at gmail.com>
Date: Sat Nov 23 21:40:44 2013 -0800
Add invalid passing async.memoize() test
This demonstrates the problem described in #304
---
test/test-async.js | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/test/test-async.js b/test/test-async.js
index ff401e7..b92168a 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2219,6 +2219,45 @@ exports['memoize'] = function (test) {
test.done();
};
+exports['memoize maintains asynchrony'] = function (test) {
+ test.expect(3);
+ var call_order = [];
+
+ var fn = function (arg1, arg2, callback) {
+ call_order.push(['fn', arg1, arg2]);
+ async.setImmediate(function () {
+ call_order.push(['cb', 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);
+ async.nextTick(memoize_done);
+ call_order.push('tick3');
+ });
+ call_order.push('tick2');
+ });
+ call_order.push('tick1');
+
+ function memoize_done() {
+ var zalgo_call_order = [
+ ['fn',1,2], // initial async call
+ 'tick1', // async caller
+ ['cb',1,2], // async callback
+ // ['fn',1,2], // memoized // memoized async body
+ // ['cb',1,2], // memoized // memoized async response body
+ 'tick3', // handler for memoized async call
+ 'tick2' // handler for first async call
+ ];
+ test.same(call_order, zalgo_call_order);
+ test.done();
+ }
+};
+
exports['unmemoize'] = function(test) {
test.expect(4);
var call_order = [];
--
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