forked from koding/koding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircular.js
More file actions
executable file
·36 lines (30 loc) · 943 Bytes
/
Copy pathcircular.js
File metadata and controls
executable file
·36 lines (30 loc) · 943 Bytes
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
var dnode = require('../');
var test = require('tap').test;
test('circular refs', function (t) {
t.plan(7);
var port = Math.floor(Math.random() * 40000 + 10000);
var server = dnode({
sendObj : function (ref, f) {
t.equal(ref.a, 1);
t.equal(ref.b, 2);
t.deepEqual(ref.c, ref);
ref.d = ref.c;
f(ref);
},
}).listen(port);
server.on('ready', function () {
dnode.connect(port, function (remote, conn) {
var obj = { a : 1, b : 2 };
obj.c = obj;
remote.sendObj(obj, function (ref) {
t.equal(ref.a, 1);
t.equal(ref.b, 2);
t.deepEqual(ref.c, ref);
t.deepEqual(ref.d, ref);
conn.end();
server.close();
t.end();
});
});
});
});