test.js
1.08 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var assert = require('assert');
var eos = require('./index');
var expected = 6;
var fs = require('fs');
var net = require('net');
var ws = fs.createWriteStream('/dev/null');
eos(ws, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
ws.close();
var rs = fs.createReadStream('/dev/random');
eos(rs, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
rs.close();
var rs = fs.createReadStream(__filename);
eos(rs, function(err) {
expected--;
assert(!err);
if (!expected) process.exit(0);
});
rs.pipe(fs.createWriteStream('/dev/null'));
var socket = net.connect(50000);
eos(socket, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
var server = net.createServer(function(socket) {
eos(socket, function() {
expected--;
if (!expected) process.exit(0);
});
socket.destroy();
}).listen(30000, function() {
var socket = net.connect(30000);
eos(socket, function() {
expected--;
if (!expected) process.exit(0);
});
});
setTimeout(function() {
assert(expected === 0);
process.exit(0);
}, 1000);