Skip to content

Commit 018e110

Browse files
committed
test: replace .addListener() calls with .on()
1 parent 3108a9e commit 018e110

File tree

126 files changed

+421
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+421
-421
lines changed

test/disabled/test-cat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ promise.addErrback(function() {
7070
errors += 1;
7171
});
7272

73-
process.addListener('exit', function() {
73+
process.on('exit', function() {
7474
assert.equal(2, successes);
7575
assert.equal(0, errors);
7676
});

test/disabled/test-child-process-custom-fds.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function test1(next) {
5050
assert.equal(child.stdout, null);
5151
assert.notEqual(child.stderr, null);
5252

53-
child.addListener('exit', function(err) {
53+
child.on('exit', function(err) {
5454
if (err) throw err;
5555
fs.close(fd, function(error) {
5656
if (error) throw error;
@@ -77,10 +77,10 @@ function test2(next) {
7777

7878
assert.equal(child.stdin, null);
7979
var actualData = '';
80-
child.stdout.addListener('data', function(data) {
80+
child.stdout.on('data', function(data) {
8181
actualData += data.toString();
8282
});
83-
child.addListener('exit', function(code) {
83+
child.on('exit', function(code) {
8484
if (err) throw err;
8585
assert.equal(actualData, 'hella warld\n');
8686
console.log(' File was filtered successfully');
@@ -98,16 +98,16 @@ function test3(next) {
9898
var filter = spawn(process.argv[0], [fixtPath('stdio-filter.js'), 'o', 'a']);
9999
var echo = spawn('/bin/echo', [expected], {customFds: [-1, filter.fds[0]]});
100100
var actualData = '';
101-
filter.stdout.addListener('data', function(data) {
101+
filter.stdout.on('data', function(data) {
102102
console.log(' Got data --> ' + data);
103103
actualData += data;
104104
});
105-
filter.addListener('exit', function(code) {
105+
filter.on('exit', function(code) {
106106
if (code) throw 'Return code was ' + code;
107107
assert.equal(actualData, 'hella warld\n');
108108
console.log(' Talked to another process successfully');
109109
});
110-
echo.addListener('exit', function(code) {
110+
echo.on('exit', function(code) {
111111
if (code) throw 'Return code was ' + code;
112112
filter.stdin.end();
113113
fs.unlinkSync(helloPath);

test/disabled/test-fs-sendfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var x = path.join(common.fixturesDir, 'x.txt');
3131
var expected = 'xyz';
3232

3333
var server = net.createServer(function(socket) {
34-
socket.addListener('receive', function(data) {
34+
socket.on('receive', function(data) {
3535
found = data;
3636
client.close();
3737
socket.close();
@@ -42,7 +42,7 @@ var server = net.createServer(function(socket) {
4242
server.listen(common.PORT);
4343

4444
var client = net.createConnection(common.PORT);
45-
client.addListener('connect', function() {
45+
client.on('connect', function() {
4646
fs.open(x, 'r').addCallback(function(fd) {
4747
fs.sendfile(client.fd, fd, 0, expected.length)
4848
.addCallback(function(size) {

test/disabled/test-http-big-proxy-responses.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ var proxy = http.createServer(function(req, res) {
6868

6969
var count = 0;
7070

71-
proxy_res.addListener('data', function(d) {
71+
proxy_res.on('data', function(d) {
7272
if (count++ % 1000 == 0) common.print('.');
7373
res.write(d);
7474
sent += d.length;
7575
assert.ok(sent <= (len * chunk.length));
7676
});
7777

78-
proxy_res.addListener('end', function() {
78+
proxy_res.on('end', function() {
7979
res.end();
8080
});
8181

@@ -102,12 +102,12 @@ function call_chargen(list) {
102102
headers: {'x-len': len}
103103
}, function(res) {
104104

105-
res.addListener('data', function(d) {
105+
res.on('data', function(d) {
106106
recved += d.length;
107107
assert.ok(recved <= (len * chunk.length));
108108
});
109109

110-
res.addListener('end', function() {
110+
res.on('end', function() {
111111
assert.ok(recved <= (len * chunk.length));
112112
common.debug('end for ' + len + ' chunks.');
113113
call_chargen(list);
@@ -130,6 +130,6 @@ function ready() {
130130
call_chargen([100, 1000, 10000, 100000, 1000000]);
131131
}
132132

133-
process.addListener('exit', function() {
133+
process.on('exit', function() {
134134
assert.ok(done);
135135
});

test/disabled/test-http-head-request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ server.listen(common.PORT);
4444

4545
var gotEnd = false;
4646

47-
server.addListener('listening', function() {
47+
server.on('listening', function() {
4848
var request = http.request({
4949
port: common.PORT,
5050
method: 'HEAD',
5151
path: '/'
5252
}, function(response) {
5353
console.log('got response');
54-
response.addListener('data', function() {
54+
response.on('data', function() {
5555
process.exit(2);
5656
});
57-
response.addListener('end', function() {
57+
response.on('end', function() {
5858
process.exit(0);
5959
});
6060
});

test/disabled/test-http-stress.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ server.listen(common.PORT);
4040
var requests_ok = 0;
4141
var requests_complete = 0;
4242

43-
server.addListener('listening', function() {
43+
server.on('listening', function() {
4444
for (var i = 0; i < request_count; i++) {
4545
http.cat('http://localhost:' + common.PORT + '/', 'utf8',
4646
function(err, content) {
@@ -60,7 +60,7 @@ server.addListener('listening', function() {
6060
}
6161
});
6262

63-
process.addListener('exit', function() {
63+
process.on('exit', function() {
6464
assert.equal(request_count, requests_complete);
6565
assert.equal(request_count, requests_ok);
6666
});

test/disabled/test-http-tls.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ var https_server = http.createServer(function(req, res) {
111111
https_server.setSecure(credentials);
112112
https_server.listen(common.PORT);
113113

114-
https_server.addListener('listening', function() {
114+
https_server.on('listening', function() {
115115
var c = net.createConnection(common.PORT);
116116

117117
c.setEncoding('utf8');
118118

119-
c.addListener('connect', function() {
119+
c.on('connect', function() {
120120
c.setSecure(credentials);
121121
});
122122

123-
c.addListener('secure', function() {
123+
c.on('secure', function() {
124124
var verified = c.verifyPeer();
125125
var peerDN = JSON.stringify(c.getPeerCertificate());
126126
assert.equal(verified, true);
@@ -137,7 +137,7 @@ https_server.addListener('listening', function() {
137137
requests_sent += 1;
138138
});
139139

140-
c.addListener('data', function(chunk) {
140+
c.on('data', function(chunk) {
141141
server_response += chunk;
142142

143143
if (requests_sent == 1) {
@@ -155,16 +155,16 @@ https_server.addListener('listening', function() {
155155

156156
});
157157

158-
c.addListener('end', function() {
158+
c.on('end', function() {
159159
client_got_eof = true;
160160
});
161161

162-
c.addListener('close', function() {
162+
c.on('close', function() {
163163
assert.equal(c.readyState, 'closed');
164164
});
165165
});
166166

167-
process.addListener('exit', function() {
167+
process.on('exit', function() {
168168
assert.equal(4, request_number);
169169
assert.equal(4, requests_sent);
170170

test/disabled/test-idle-watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ idle.callback = function() {
3434
idle.setPriority(process.EVMAXPRI);
3535
idle.start();
3636

37-
process.addListener('exit', function() {
37+
process.on('exit', function() {
3838
assert.ok(complete);
3939
});

test/disabled/test-net-fd-passing.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ function fdPassingTest(path, port) {
4141
var initializeSender = function() {
4242
var fdHighway = new net.Socket();
4343

44-
fdHighway.addListener('connect', function() {
44+
fdHighway.on('connect', function() {
4545
var sender = net.createServer(function(socket) {
4646
fdHighway.sendFD(socket);
4747
socket.flush();
4848
socket.forceClose(); // want to close() the fd, not shutdown()
4949
});
5050

51-
sender.addListener('listening', function() {
51+
sender.on('listening', function() {
5252
var client = net.createConnection(port);
5353

54-
client.addListener('connect', function() {
54+
client.on('connect', function() {
5555
client.write(message);
5656
});
5757

58-
client.addListener('data', function(data) {
58+
client.on('data', function(data) {
5959
assert.equal(expectedData[0], data);
6060
if (expectedData.length > 1) {
6161
expectedData.shift();
@@ -78,7 +78,7 @@ function fdPassingTest(path, port) {
7878

7979
};
8080

81-
receiver.addListener('output', function(data) {
81+
receiver.on('output', function(data) {
8282
var initialized = false;
8383
if ((! initialized) && (data == 'ready')) {
8484
initializeSender();
@@ -89,6 +89,6 @@ function fdPassingTest(path, port) {
8989

9090
fdPassingTest('/tmp/passing-socket-test', 31075);
9191

92-
process.addListener('exit', function() {
92+
process.on('exit', function() {
9393
assert.equal(1, tests_run);
9494
});

test/disabled/test-net-tls-pummel.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
4747
socket.setNoDelay();
4848
socket.timeout = 0;
4949

50-
socket.addListener('data', function(data) {
50+
socket.on('data', function(data) {
5151
var verified = socket.verifyPeer();
5252
var peerDN = socket.getPeerCertificate('DNstring');
5353
assert.equal(verified, 1);
@@ -62,12 +62,12 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
6262
}
6363
});
6464

65-
socket.addListener('end', function() {
65+
socket.on('end', function() {
6666
assert.equal('writeOnly', socket.readyState);
6767
socket.end();
6868
});
6969

70-
socket.addListener('close', function(had_error) {
70+
socket.on('close', function(had_error) {
7171
assert.equal(false, had_error);
7272
assert.equal('closed', socket.readyState);
7373
socket.server.close();
@@ -82,7 +82,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
8282
client.setEncoding('utf8');
8383
client.setSecure('X509_PEM', caPem, 0, keyPem, caPem);
8484

85-
client.addListener('connect', function() {
85+
client.on('connect', function() {
8686
assert.equal('open', client.readyState);
8787
var verified = client.verifyPeer();
8888
var peerDN = client.getPeerCertificate('DNstring');
@@ -93,7 +93,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
9393
client.write('PING');
9494
});
9595

96-
client.addListener('data', function(data) {
96+
client.on('data', function(data) {
9797
assert.equal('PONG', data);
9898
count += 1;
9999

@@ -115,7 +115,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
115115
}
116116
});
117117

118-
client.addListener('close', function() {
118+
client.on('close', function() {
119119
assert.equal(N + 1, count);
120120
assert.equal(true, sent_final_ping);
121121
tests_run += 1;
@@ -141,7 +141,7 @@ if (have_tls) {
141141
tlsTest(common.PORT, 'localhost', caPem, keyPem, certPem);
142142
tlsTest(common.PORT + 1, null, caPem, keyPem, certPem);
143143

144-
process.addListener('exit', function() {
144+
process.on('exit', function() {
145145
assert.equal(2, tests_run);
146146
});
147147
} else {

0 commit comments

Comments
 (0)