forked from koding/koding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble.js
More file actions
executable file
·40 lines (35 loc) · 1.1 KB
/
Copy pathdouble.js
File metadata and controls
executable file
·40 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var dnode = require('../');
var test = require('tap').test;
test('double', function (t) {
t.plan(4);
var port = Math.floor(Math.random() * 40000 + 10000);
var server = dnode({
z : function (f, g, h) {
f(10, function (x) {
g(10, function (y) {
h(x,y)
})
})
}
}).listen(port);
server.on('ready', function () {
dnode.connect(port, function (remote, conn) {
remote.z(
function (x,f) { f(x * 2) },
function (x,f) { f(x / 2) },
function (x,y) {
t.equal(x, 20, 'double, not equal');
t.equal(y, 5, 'double, not equal');
}
);
function plusTen(n,f) { f(n + 10) }
remote.z(plusTen, plusTen, function (x,y) {
t.equal(x, 20, 'double, equal');
t.equal(y, 20, 'double, equal');
conn.end();
server.close();
t.end();
});
});
});
});