Permalink
Browse files

test: replace .addListener() calls with .on()

  • Loading branch information...
1 parent 3108a9e commit 018e110cd11720997e49c9b270ecc50a04de4ece @bnoordhuis bnoordhuis committed Oct 14, 2011
Showing with 421 additions and 421 deletions.
  1. +1 −1 test/disabled/test-cat.js
  2. +6 −6 test/disabled/test-child-process-custom-fds.js
  3. +2 −2 test/disabled/test-fs-sendfile.js
  4. +5 −5 test/disabled/test-http-big-proxy-responses.js
  5. +3 −3 test/disabled/test-http-head-request.js
  6. +2 −2 test/disabled/test-http-stress.js
  7. +7 −7 test/disabled/test-http-tls.js
  8. +1 −1 test/disabled/test-idle-watcher.js
  9. +6 −6 test/disabled/test-net-fd-passing.js
  10. +7 −7 test/disabled/test-net-tls-pummel.js
  11. +9 −9 test/disabled/test-net-tls.js
  12. +2 −2 test/disabled/test-process-title.js
  13. +1 −1 test/disabled/test-remote-module-loading.js
  14. +5 −5 test/disabled/test-sendfd.js
  15. +4 −4 test/disabled/tls_client.js
  16. +3 −3 test/disabled/tls_server.js
  17. +1 −1 test/fixtures/a.js
  18. +1 −1 test/fixtures/b/c.js
  19. +1 −1 test/fixtures/b/d.js
  20. +2 −2 test/fixtures/echo.js
  21. +5 −5 test/fixtures/net-fd-passing-receiver.js
  22. +3 −3 test/fixtures/recvfd.js
  23. +1 −1 test/fixtures/should_exit.js
  24. +1 −1 test/fixtures/stdio-filter.js
  25. +4 −4 test/pummel/test-child-process-spawn-loop.js
  26. +1 −1 test/pummel/test-exec.js
  27. +1 −1 test/pummel/test-fs-watch-file.js
  28. +4 −4 test/pummel/test-http-client-reconnect-bug.js
  29. +1 −1 test/pummel/test-keep-alive.js
  30. +7 −7 test/pummel/test-net-many-clients.js
  31. +3 −3 test/pummel/test-net-pause.js
  32. +9 −9 test/pummel/test-net-pingpong-delay.js
  33. +7 −7 test/pummel/test-net-pingpong.js
  34. +4 −4 test/pummel/test-net-throttle.js
  35. +10 −10 test/pummel/test-net-timeout.js
  36. +1 −1 test/pummel/test-timers.js
  37. +1 −1 test/pummel/test-watch-file.js
  38. +3 −3 test/simple/test-child-process-buffering.js
  39. +3 −3 test/simple/test-child-process-cwd.js
  40. +2 −2 test/simple/test-child-process-env.js
  41. +1 −1 test/simple/test-child-process-exec-cwd.js
  42. +2 −2 test/simple/test-child-process-exec-env.js
  43. +3 −3 test/simple/test-child-process-exit-code.js
  44. +4 −4 test/simple/test-child-process-ipc.js
  45. +6 −6 test/simple/test-child-process-kill.js
  46. +6 −6 test/simple/test-child-process-stdin.js
  47. +3 −3 test/simple/test-child-process-stdout-flush.js
  48. +2 −2 test/simple/test-crypto.js
  49. +1 −1 test/simple/test-delayed-require.js
  50. +2 −2 test/simple/test-dgram-pingpong.js
  51. +1 −1 test/simple/test-eio-race.js
  52. +1 −1 test/simple/test-eio-race4.js
  53. +1 −1 test/simple/test-error-reporting.js
  54. +1 −1 test/simple/test-eval.js
  55. +2 −2 test/simple/test-event-emitter-add-listeners.js
  56. +7 −7 test/simple/test-event-emitter-modify-in-emit.js
  57. +1 −1 test/simple/test-event-emitter-num-args.js
  58. +1 −1 test/simple/test-event-emitter-once.js
  59. +4 −4 test/simple/test-event-emitter-remove-all-listeners.js
  60. +4 −4 test/simple/test-event-emitter-remove-listeners.js
  61. +3 −3 test/simple/test-exception-handler.js
  62. +1 −1 test/simple/test-file-read-noexist.js
  63. +5 −5 test/simple/test-file-write-stream.js
  64. +1 −1 test/simple/test-fs-chmod.js
  65. +1 −1 test/simple/test-fs-error-messages.js
  66. +1 −1 test/simple/test-fs-fsync.js
  67. +1 −1 test/simple/test-fs-open.js
  68. +1 −1 test/simple/test-fs-read-buffer.js
  69. +11 −11 test/simple/test-fs-read-stream.js
  70. +1 −1 test/simple/test-fs-read.js
  71. +1 −1 test/simple/test-fs-realpath.js
  72. +1 −1 test/simple/test-fs-stat.js
  73. +1 −1 test/simple/test-fs-symlink.js
  74. +1 −1 test/simple/test-fs-watch.js
  75. +1 −1 test/simple/test-fs-write-buffer.js
  76. +1 −1 test/simple/test-fs-write-file.js
  77. +1 −1 test/simple/test-fs-write-stream.js
  78. +1 −1 test/simple/test-fs-write.js
  79. +4 −4 test/simple/test-http-blank-header.js
  80. +2 −2 test/simple/test-http-client-parse-error.js
  81. +11 −11 test/simple/test-http-client-race-2.js
  82. +8 −8 test/simple/test-http-client-race.js
  83. +6 −6 test/simple/test-http-client-upload-buf.js
  84. +6 −6 test/simple/test-http-client-upload.js
  85. +3 −3 test/simple/test-http-eof-on-connect.js
  86. +1 −1 test/simple/test-http-exceptions.js
  87. +6 −6 test/simple/test-http-expect-continue.js
  88. +1 −1 test/simple/test-http-full-response.js
  89. +2 −2 test/simple/test-http-head-request.js
  90. +3 −3 test/simple/test-http-head-response-has-no-body-end.js
  91. +3 −3 test/simple/test-http-head-response-has-no-body.js
  92. +2 −2 test/simple/test-http-keep-alive-close-on-header.js
  93. +1 −1 test/simple/test-http-keep-alive.js
  94. +3 −3 test/simple/test-http-malformed-request.js
  95. +5 −5 test/simple/test-http-proxy.js
  96. +1 −1 test/simple/test-http-response-close.js
  97. +6 −6 test/simple/test-http-server.js
  98. +6 −6 test/simple/test-http-set-cookies.js
  99. +1 −1 test/simple/test-http-set-timeout.js
  100. +9 −9 test/simple/test-http-set-trailers.js
  101. +3 −3 test/simple/test-http-upgrade-agent.js
  102. +4 −4 test/simple/test-http-upgrade-client.js
  103. +13 −13 test/simple/test-http-upgrade-server.js
  104. +6 −6 test/simple/test-http-upgrade-server2.js
  105. +6 −6 test/simple/test-http-wget.js
  106. +2 −2 test/simple/test-http-write-empty-string.js
  107. +5 −5 test/simple/test-http.js
  108. +1 −1 test/simple/test-mkdir-rmdir.js
  109. +1 −1 test/simple/test-module-loading.js
  110. +7 −7 test/simple/test-net-binary.js
  111. +1 −1 test/simple/test-net-eaddrinuse.js
  112. +2 −2 test/simple/test-net-keepalive.js
  113. +9 −9 test/simple/test-net-pingpong.js
  114. +7 −7 test/simple/test-net-reconnect.js
  115. +2 −2 test/simple/test-next-tick-errors.js
  116. +1 −1 test/simple/test-next-tick-ordering.js
  117. +1 −1 test/simple/test-next-tick-ordering2.js
  118. +1 −1 test/simple/test-next-tick.js
  119. +1 −1 test/simple/test-pipe-head.js
  120. +4 −4 test/simple/test-pump-file2tcp-noexist.js
  121. +5 −5 test/simple/test-pump-file2tcp.js
  122. +1 −1 test/simple/test-readdir.js
  123. +12 −12 test/simple/test-repl.js
  124. +6 −6 test/simple/test-signal-handler.js
  125. +2 −2 test/simple/test-signal-unregister.js
  126. +1 −1 test/simple/test-stdout-to-file.js
@@ -70,7 +70,7 @@ promise.addErrback(function() {
errors += 1;
});
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.equal(2, successes);
assert.equal(0, errors);
});
@@ -50,7 +50,7 @@ function test1(next) {
assert.equal(child.stdout, null);
assert.notEqual(child.stderr, null);
- child.addListener('exit', function(err) {
+ child.on('exit', function(err) {
if (err) throw err;
fs.close(fd, function(error) {
if (error) throw error;
@@ -77,10 +77,10 @@ function test2(next) {
assert.equal(child.stdin, null);
var actualData = '';
- child.stdout.addListener('data', function(data) {
+ child.stdout.on('data', function(data) {
actualData += data.toString();
});
- child.addListener('exit', function(code) {
+ child.on('exit', function(code) {
if (err) throw err;
assert.equal(actualData, 'hella warld\n');
console.log(' File was filtered successfully');
@@ -98,16 +98,16 @@ function test3(next) {
var filter = spawn(process.argv[0], [fixtPath('stdio-filter.js'), 'o', 'a']);
var echo = spawn('/bin/echo', [expected], {customFds: [-1, filter.fds[0]]});
var actualData = '';
- filter.stdout.addListener('data', function(data) {
+ filter.stdout.on('data', function(data) {
console.log(' Got data --> ' + data);
actualData += data;
});
- filter.addListener('exit', function(code) {
+ filter.on('exit', function(code) {
if (code) throw 'Return code was ' + code;
assert.equal(actualData, 'hella warld\n');
console.log(' Talked to another process successfully');
});
- echo.addListener('exit', function(code) {
+ echo.on('exit', function(code) {
if (code) throw 'Return code was ' + code;
filter.stdin.end();
fs.unlinkSync(helloPath);
@@ -31,7 +31,7 @@ var x = path.join(common.fixturesDir, 'x.txt');
var expected = 'xyz';
var server = net.createServer(function(socket) {
- socket.addListener('receive', function(data) {
+ socket.on('receive', function(data) {
found = data;
client.close();
socket.close();
@@ -42,7 +42,7 @@ var server = net.createServer(function(socket) {
server.listen(common.PORT);
var client = net.createConnection(common.PORT);
-client.addListener('connect', function() {
+client.on('connect', function() {
fs.open(x, 'r').addCallback(function(fd) {
fs.sendfile(client.fd, fd, 0, expected.length)
.addCallback(function(size) {
@@ -68,14 +68,14 @@ var proxy = http.createServer(function(req, res) {
var count = 0;
- proxy_res.addListener('data', function(d) {
+ proxy_res.on('data', function(d) {
if (count++ % 1000 == 0) common.print('.');
res.write(d);
sent += d.length;
assert.ok(sent <= (len * chunk.length));
});
- proxy_res.addListener('end', function() {
+ proxy_res.on('end', function() {
res.end();
});
@@ -102,12 +102,12 @@ function call_chargen(list) {
headers: {'x-len': len}
}, function(res) {
- res.addListener('data', function(d) {
+ res.on('data', function(d) {
recved += d.length;
assert.ok(recved <= (len * chunk.length));
});
- res.addListener('end', function() {
+ res.on('end', function() {
assert.ok(recved <= (len * chunk.length));
common.debug('end for ' + len + ' chunks.');
call_chargen(list);
@@ -130,6 +130,6 @@ function ready() {
call_chargen([100, 1000, 10000, 100000, 1000000]);
}
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.ok(done);
});
@@ -44,17 +44,17 @@ server.listen(common.PORT);
var gotEnd = false;
-server.addListener('listening', function() {
+server.on('listening', function() {
var request = http.request({
port: common.PORT,
method: 'HEAD',
path: '/'
}, function(response) {
console.log('got response');
- response.addListener('data', function() {
+ response.on('data', function() {
process.exit(2);
});
- response.addListener('end', function() {
+ response.on('end', function() {
process.exit(0);
});
});
@@ -40,7 +40,7 @@ server.listen(common.PORT);
var requests_ok = 0;
var requests_complete = 0;
-server.addListener('listening', function() {
+server.on('listening', function() {
for (var i = 0; i < request_count; i++) {
http.cat('http://localhost:' + common.PORT + '/', 'utf8',
function(err, content) {
@@ -60,7 +60,7 @@ server.addListener('listening', function() {
}
});
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.equal(request_count, requests_complete);
assert.equal(request_count, requests_ok);
});
@@ -111,16 +111,16 @@ var https_server = http.createServer(function(req, res) {
https_server.setSecure(credentials);
https_server.listen(common.PORT);
-https_server.addListener('listening', function() {
+https_server.on('listening', function() {
var c = net.createConnection(common.PORT);
c.setEncoding('utf8');
- c.addListener('connect', function() {
+ c.on('connect', function() {
c.setSecure(credentials);
});
- c.addListener('secure', function() {
+ c.on('secure', function() {
var verified = c.verifyPeer();
var peerDN = JSON.stringify(c.getPeerCertificate());
assert.equal(verified, true);
@@ -137,7 +137,7 @@ https_server.addListener('listening', function() {
requests_sent += 1;
});
- c.addListener('data', function(chunk) {
+ c.on('data', function(chunk) {
server_response += chunk;
if (requests_sent == 1) {
@@ -155,16 +155,16 @@ https_server.addListener('listening', function() {
});
- c.addListener('end', function() {
+ c.on('end', function() {
client_got_eof = true;
});
- c.addListener('close', function() {
+ c.on('close', function() {
assert.equal(c.readyState, 'closed');
});
});
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.equal(4, request_number);
assert.equal(4, requests_sent);
@@ -34,6 +34,6 @@ idle.callback = function() {
idle.setPriority(process.EVMAXPRI);
idle.start();
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.ok(complete);
});
@@ -41,21 +41,21 @@ function fdPassingTest(path, port) {
var initializeSender = function() {
var fdHighway = new net.Socket();
- fdHighway.addListener('connect', function() {
+ fdHighway.on('connect', function() {
var sender = net.createServer(function(socket) {
fdHighway.sendFD(socket);
socket.flush();
socket.forceClose(); // want to close() the fd, not shutdown()
});
- sender.addListener('listening', function() {
+ sender.on('listening', function() {
var client = net.createConnection(port);
- client.addListener('connect', function() {
+ client.on('connect', function() {
client.write(message);
});
- client.addListener('data', function(data) {
+ client.on('data', function(data) {
assert.equal(expectedData[0], data);
if (expectedData.length > 1) {
expectedData.shift();
@@ -78,7 +78,7 @@ function fdPassingTest(path, port) {
};
- receiver.addListener('output', function(data) {
+ receiver.on('output', function(data) {
var initialized = false;
if ((! initialized) && (data == 'ready')) {
initializeSender();
@@ -89,6 +89,6 @@ function fdPassingTest(path, port) {
fdPassingTest('/tmp/passing-socket-test', 31075);
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.equal(1, tests_run);
});
@@ -47,7 +47,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
socket.setNoDelay();
socket.timeout = 0;
- socket.addListener('data', function(data) {
+ socket.on('data', function(data) {
var verified = socket.verifyPeer();
var peerDN = socket.getPeerCertificate('DNstring');
assert.equal(verified, 1);
@@ -62,12 +62,12 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
}
});
- socket.addListener('end', function() {
+ socket.on('end', function() {
assert.equal('writeOnly', socket.readyState);
socket.end();
});
- socket.addListener('close', function(had_error) {
+ socket.on('close', function(had_error) {
assert.equal(false, had_error);
assert.equal('closed', socket.readyState);
socket.server.close();
@@ -82,7 +82,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
client.setEncoding('utf8');
client.setSecure('X509_PEM', caPem, 0, keyPem, caPem);
- client.addListener('connect', function() {
+ client.on('connect', function() {
assert.equal('open', client.readyState);
var verified = client.verifyPeer();
var peerDN = client.getPeerCertificate('DNstring');
@@ -93,7 +93,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
client.write('PING');
});
- client.addListener('data', function(data) {
+ client.on('data', function(data) {
assert.equal('PONG', data);
count += 1;
@@ -115,7 +115,7 @@ function tlsTest(port, host, caPem, keyPem, certPem) {
}
});
- client.addListener('close', function() {
+ client.on('close', function() {
assert.equal(N + 1, count);
assert.equal(true, sent_final_ping);
tests_run += 1;
@@ -141,7 +141,7 @@ if (have_tls) {
tlsTest(common.PORT, 'localhost', caPem, keyPem, certPem);
tlsTest(common.PORT + 1, null, caPem, keyPem, certPem);
- process.addListener('exit', function() {
+ process.on('exit', function() {
assert.equal(2, tests_run);
});
} else {
@@ -63,7 +63,7 @@ var secureServer = net.createServer(function(connection) {
connection.setSecure(credentials);
connection.setEncoding('UTF8');
- connection.addListener('secure', function() {
+ connection.on('secure', function() {
gotSecureServer = true;
var verified = connection.verifyPeer();
var peerDN = JSON.stringify(connection.getPeerCertificate());
@@ -80,28 +80,28 @@ var secureServer = net.createServer(function(connection) {
});
- connection.addListener('data', function(chunk) {
+ connection.on('data', function(chunk) {
serverData += chunk;
connection.write(chunk);
});
- connection.addListener('end', function() {
+ connection.on('end', function() {
assert.equal(serverData, testData);
connection.end();
self.close();
});
});
secureServer.listen(common.PORT);
-secureServer.addListener('listening', function() {
+secureServer.on('listening', function() {
var secureClient = net.createConnection(common.PORT);
secureClient.setEncoding('UTF8');
- secureClient.addListener('connect', function() {
+ secureClient.on('connect', function() {
secureClient.setSecure(credentials);
});
- secureClient.addListener('secure', function() {
+ secureClient.on('secure', function() {
gotSecureClient = true;
var verified = secureClient.verifyPeer();
var peerDN = JSON.stringify(secureClient.getPeerCertificate());
@@ -120,16 +120,16 @@ secureServer.addListener('listening', function() {
secureClient.end();
});
- secureClient.addListener('data', function(chunk) {
+ secureClient.on('data', function(chunk) {
clientData += chunk;
});
- secureClient.addListener('end', function() {
+ secureClient.on('end', function() {
assert.equal(clientData, testData);
});
});
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.ok(gotSecureServer, 'Did not get secure event for server');
assert.ok(gotSecureClient, 'Did not get secure event for client');
});
@@ -40,8 +40,8 @@ function verifyProcessName(str, callback) {
var buf = '';
ps = spawn('ps');
ps.stdout.setEncoding('utf8');
- ps.stdout.addListener('data', function(s) { buf += s; });
- ps.addListener('exit', function(c) {
+ ps.stdout.on('data', function(s) { buf += s; });
+ ps.on('exit', function(c) {
try {
assert.equal(0, c);
assert.ok(new RegExp(process.pid + ' ', 'm').test(buf));
@@ -57,6 +57,6 @@ util.exec(cmd, function(err, stdout, stderr) {
server.close();
});
-process.addListener('exit', function() {
+process.on('exit', function() {
assert.equal(1, modulesLoaded);
});
Oops, something went wrong.

0 comments on commit 018e110

Please sign in to comment.