From 018e110cd11720997e49c9b270ecc50a04de4ece Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 15 Oct 2011 01:08:36 +0200 Subject: [PATCH] test: replace .addListener() calls with .on() --- test/disabled/test-cat.js | 2 +- .../disabled/test-child-process-custom-fds.js | 12 ++++----- test/disabled/test-fs-sendfile.js | 4 +-- .../disabled/test-http-big-proxy-responses.js | 10 +++---- test/disabled/test-http-head-request.js | 6 ++--- test/disabled/test-http-stress.js | 4 +-- test/disabled/test-http-tls.js | 14 +++++----- test/disabled/test-idle-watcher.js | 2 +- test/disabled/test-net-fd-passing.js | 12 ++++----- test/disabled/test-net-tls-pummel.js | 14 +++++----- test/disabled/test-net-tls.js | 18 ++++++------- test/disabled/test-process-title.js | 4 +-- test/disabled/test-remote-module-loading.js | 2 +- test/disabled/test-sendfd.js | 10 +++---- test/disabled/tls_client.js | 8 +++--- test/disabled/tls_server.js | 6 ++--- test/fixtures/a.js | 2 +- test/fixtures/b/c.js | 2 +- test/fixtures/b/d.js | 2 +- test/fixtures/echo.js | 4 +-- test/fixtures/net-fd-passing-receiver.js | 10 +++---- test/fixtures/recvfd.js | 6 ++--- test/fixtures/should_exit.js | 2 +- test/fixtures/stdio-filter.js | 2 +- test/pummel/test-child-process-spawn-loop.js | 8 +++--- test/pummel/test-exec.js | 2 +- test/pummel/test-fs-watch-file.js | 2 +- test/pummel/test-http-client-reconnect-bug.js | 8 +++--- test/pummel/test-keep-alive.js | 2 +- test/pummel/test-net-many-clients.js | 14 +++++----- test/pummel/test-net-pause.js | 6 ++--- test/pummel/test-net-pingpong-delay.js | 18 ++++++------- test/pummel/test-net-pingpong.js | 14 +++++----- test/pummel/test-net-throttle.js | 8 +++--- test/pummel/test-net-timeout.js | 20 +++++++------- test/pummel/test-timers.js | 2 +- test/pummel/test-watch-file.js | 2 +- test/simple/test-child-process-buffering.js | 6 ++--- test/simple/test-child-process-cwd.js | 6 ++--- test/simple/test-child-process-env.js | 4 +-- test/simple/test-child-process-exec-cwd.js | 2 +- test/simple/test-child-process-exec-env.js | 4 +-- test/simple/test-child-process-exit-code.js | 6 ++--- test/simple/test-child-process-ipc.js | 8 +++--- test/simple/test-child-process-kill.js | 12 ++++----- test/simple/test-child-process-stdin.js | 12 ++++----- .../simple/test-child-process-stdout-flush.js | 6 ++--- test/simple/test-crypto.js | 4 +-- test/simple/test-delayed-require.js | 2 +- test/simple/test-dgram-pingpong.js | 4 +-- test/simple/test-eio-race.js | 2 +- test/simple/test-eio-race4.js | 2 +- test/simple/test-error-reporting.js | 2 +- test/simple/test-eval.js | 2 +- .../test-event-emitter-add-listeners.js | 4 +-- .../test-event-emitter-modify-in-emit.js | 14 +++++----- test/simple/test-event-emitter-num-args.js | 2 +- test/simple/test-event-emitter-once.js | 2 +- ...test-event-emitter-remove-all-listeners.js | 8 +++--- .../test-event-emitter-remove-listeners.js | 8 +++--- test/simple/test-exception-handler.js | 6 ++--- test/simple/test-file-read-noexist.js | 2 +- test/simple/test-file-write-stream.js | 10 +++---- test/simple/test-fs-chmod.js | 2 +- test/simple/test-fs-error-messages.js | 2 +- test/simple/test-fs-fsync.js | 2 +- test/simple/test-fs-open.js | 2 +- test/simple/test-fs-read-buffer.js | 2 +- test/simple/test-fs-read-stream.js | 22 ++++++++-------- test/simple/test-fs-read.js | 2 +- test/simple/test-fs-realpath.js | 2 +- test/simple/test-fs-stat.js | 2 +- test/simple/test-fs-symlink.js | 2 +- test/simple/test-fs-watch.js | 2 +- test/simple/test-fs-write-buffer.js | 2 +- test/simple/test-fs-write-file.js | 2 +- test/simple/test-fs-write-stream.js | 2 +- test/simple/test-fs-write.js | 2 +- test/simple/test-http-blank-header.js | 8 +++--- test/simple/test-http-client-parse-error.js | 4 +-- test/simple/test-http-client-race-2.js | 22 ++++++++-------- test/simple/test-http-client-race.js | 16 ++++++------ test/simple/test-http-client-upload-buf.js | 12 ++++----- test/simple/test-http-client-upload.js | 12 ++++----- test/simple/test-http-eof-on-connect.js | 6 ++--- test/simple/test-http-exceptions.js | 2 +- test/simple/test-http-expect-continue.js | 12 ++++----- test/simple/test-http-full-response.js | 2 +- test/simple/test-http-head-request.js | 4 +-- ...test-http-head-response-has-no-body-end.js | 6 ++--- .../test-http-head-response-has-no-body.js | 6 ++--- .../test-http-keep-alive-close-on-header.js | 4 +-- test/simple/test-http-keep-alive.js | 2 +- test/simple/test-http-malformed-request.js | 6 ++--- test/simple/test-http-proxy.js | 10 +++---- test/simple/test-http-response-close.js | 2 +- test/simple/test-http-server.js | 12 ++++----- test/simple/test-http-set-cookies.js | 12 ++++----- test/simple/test-http-set-timeout.js | 2 +- test/simple/test-http-set-trailers.js | 18 ++++++------- test/simple/test-http-upgrade-agent.js | 6 ++--- test/simple/test-http-upgrade-client.js | 8 +++--- test/simple/test-http-upgrade-server.js | 26 +++++++++---------- test/simple/test-http-upgrade-server2.js | 12 ++++----- test/simple/test-http-wget.js | 12 ++++----- test/simple/test-http-write-empty-string.js | 4 +-- test/simple/test-http.js | 10 +++---- test/simple/test-mkdir-rmdir.js | 2 +- test/simple/test-module-loading.js | 2 +- test/simple/test-net-binary.js | 14 +++++----- test/simple/test-net-eaddrinuse.js | 2 +- test/simple/test-net-keepalive.js | 4 +-- test/simple/test-net-pingpong.js | 18 ++++++------- test/simple/test-net-reconnect.js | 14 +++++----- test/simple/test-next-tick-errors.js | 4 +-- test/simple/test-next-tick-ordering.js | 2 +- test/simple/test-next-tick-ordering2.js | 2 +- test/simple/test-next-tick.js | 2 +- test/simple/test-pipe-head.js | 2 +- test/simple/test-pump-file2tcp-noexist.js | 8 +++--- test/simple/test-pump-file2tcp.js | 10 +++---- test/simple/test-readdir.js | 2 +- test/simple/test-repl.js | 24 ++++++++--------- test/simple/test-signal-handler.js | 12 ++++----- test/simple/test-signal-unregister.js | 4 +-- test/simple/test-stdout-to-file.js | 2 +- 126 files changed, 421 insertions(+), 421 deletions(-) diff --git a/test/disabled/test-cat.js b/test/disabled/test-cat.js index 9210ec570d..cfda7e0a5f 100644 --- a/test/disabled/test-cat.js +++ b/test/disabled/test-cat.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); }); diff --git a/test/disabled/test-child-process-custom-fds.js b/test/disabled/test-child-process-custom-fds.js index 690f89d6d7..c0e4a0aaff 100644 --- a/test/disabled/test-child-process-custom-fds.js +++ b/test/disabled/test-child-process-custom-fds.js @@ -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); diff --git a/test/disabled/test-fs-sendfile.js b/test/disabled/test-fs-sendfile.js index 4dc8e37ee5..170e393c0d 100644 --- a/test/disabled/test-fs-sendfile.js +++ b/test/disabled/test-fs-sendfile.js @@ -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) { diff --git a/test/disabled/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js index 2d84d9984c..b52392215d 100644 --- a/test/disabled/test-http-big-proxy-responses.js +++ b/test/disabled/test-http-big-proxy-responses.js @@ -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); }); diff --git a/test/disabled/test-http-head-request.js b/test/disabled/test-http-head-request.js index 362a33aabf..38b2b843ea 100644 --- a/test/disabled/test-http-head-request.js +++ b/test/disabled/test-http-head-request.js @@ -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); }); }); diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js index 7a1cee1e4f..63741ce3d3 100644 --- a/test/disabled/test-http-stress.js +++ b/test/disabled/test-http-stress.js @@ -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); }); diff --git a/test/disabled/test-http-tls.js b/test/disabled/test-http-tls.js index 9540391bf3..74102e20ba 100644 --- a/test/disabled/test-http-tls.js +++ b/test/disabled/test-http-tls.js @@ -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); diff --git a/test/disabled/test-idle-watcher.js b/test/disabled/test-idle-watcher.js index 10e78612f5..2411d15b66 100644 --- a/test/disabled/test-idle-watcher.js +++ b/test/disabled/test-idle-watcher.js @@ -34,6 +34,6 @@ idle.callback = function() { idle.setPriority(process.EVMAXPRI); idle.start(); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(complete); }); diff --git a/test/disabled/test-net-fd-passing.js b/test/disabled/test-net-fd-passing.js index 67a04b3736..1488e3baf1 100644 --- a/test/disabled/test-net-fd-passing.js +++ b/test/disabled/test-net-fd-passing.js @@ -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); }); diff --git a/test/disabled/test-net-tls-pummel.js b/test/disabled/test-net-tls-pummel.js index fa405be579..5f1358cad2 100644 --- a/test/disabled/test-net-tls-pummel.js +++ b/test/disabled/test-net-tls-pummel.js @@ -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 { diff --git a/test/disabled/test-net-tls.js b/test/disabled/test-net-tls.js index d4620065d9..9e7eae63eb 100644 --- a/test/disabled/test-net-tls.js +++ b/test/disabled/test-net-tls.js @@ -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,12 +80,12 @@ 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(); @@ -93,15 +93,15 @@ var secureServer = net.createServer(function(connection) { }); 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'); }); diff --git a/test/disabled/test-process-title.js b/test/disabled/test-process-title.js index a50fd8f591..2c3debd4ba 100644 --- a/test/disabled/test-process-title.js +++ b/test/disabled/test-process-title.js @@ -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)); diff --git a/test/disabled/test-remote-module-loading.js b/test/disabled/test-remote-module-loading.js index 7b9d7e223c..f06052c3db 100644 --- a/test/disabled/test-remote-module-loading.js +++ b/test/disabled/test-remote-module-loading.js @@ -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); }); diff --git a/test/disabled/test-sendfd.js b/test/disabled/test-sendfd.js index 328d1989e1..6af1a81091 100644 --- a/test/disabled/test-sendfd.js +++ b/test/disabled/test-sendfd.js @@ -91,7 +91,7 @@ assert.equal(pipeFDs.length, 2); var seenOrdinals = []; var pipeReadStream = new net.Stream(); -pipeReadStream.addListener('data', function(data) { +pipeReadStream.on('data', function(data) { data.toString('utf8').trim().split('\n').forEach(function(d) { var rd = JSON.parse(d); @@ -121,7 +121,7 @@ var srv = net.createServer(function(s) { if (s.write(buf, pipeFDs[1])) { netBinding.close(pipeFDs[1]); } else { - s.addListener('drain', function() { + s.on('drain', function() { netBinding.close(pipeFDs[1]); }); } @@ -133,12 +133,12 @@ var cp = child_process.spawn(process.argv[0], [path.join(common.fixturesDir, 'recvfd.js'), SOCK_PATH]); -cp.stdout.addListener('data', logChild); -cp.stderr.addListener('data', logChild); +cp.stdout.on('data', logChild); +cp.stderr.on('data', logChild); // When the child exits, clean up and validate its exit status var cpp = cp.pid; -cp.addListener('exit', function(code, signal) { +cp.on('exit', function(code, signal) { srv.close(); // fs.unlinkSync(SOCK_PATH); diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js index c9647b9bd2..89213b5c6d 100644 --- a/test/disabled/tls_client.js +++ b/test/disabled/tls_client.js @@ -45,23 +45,23 @@ try { } client.setEncoding('UTF8'); -client.addListener('connect', function() { +client.on('connect', function() { console.log('client connected.'); client.setSecure(credentials); }); -client.addListener('secure', function() { +client.on('secure', function() { console.log('client secure : ' + JSON.stringify(client.getCipher())); console.log(JSON.stringify(client.getPeerCertificate())); console.log('verifyPeer : ' + client.verifyPeer()); client.write('GET / HTTP/1.0\r\n\r\n'); }); -client.addListener('data', function(chunk) { +client.on('data', function(chunk) { common.error(chunk); }); -client.addListener('end', function() { +client.on('end', function() { console.log('client disconnected.'); }); diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index ac4b546ac0..c98c90e521 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -44,11 +44,11 @@ var server = net.createServer(function(connection) { connection.setSecure(credentials); connection.setEncoding('binary'); - connection.addListener('secure', function() { + connection.on('secure', function() { //console.log('Secure'); }); - connection.addListener('data', function(chunk) { + connection.on('data', function(chunk) { console.log('recved: ' + JSON.stringify(chunk)); connection.write('HTTP/1.0 200 OK\r\n' + 'Content-type: text/plain\r\n' + @@ -60,7 +60,7 @@ var server = net.createServer(function(connection) { connection.end(); }); - connection.addListener('end', function() { + connection.on('end', function() { connection.end(); }); diff --git a/test/fixtures/a.js b/test/fixtures/a.js index 3e4975841c..fa010b07b4 100644 --- a/test/fixtures/a.js +++ b/test/fixtures/a.js @@ -41,6 +41,6 @@ exports.D = function() { exports.number = 42; -process.addListener('exit', function() { +process.on('exit', function() { string = 'A done'; }); diff --git a/test/fixtures/b/c.js b/test/fixtures/b/c.js index a8a3a272b0..6e5080d776 100644 --- a/test/fixtures/b/c.js +++ b/test/fixtures/b/c.js @@ -43,7 +43,7 @@ exports.D = function() { return d.D(); }; -process.addListener('exit', function() { +process.on('exit', function() { string = 'C done'; console.log('b/c.js exit'); }); diff --git a/test/fixtures/b/d.js b/test/fixtures/b/d.js index ef449f6790..37fefc2d34 100644 --- a/test/fixtures/b/d.js +++ b/test/fixtures/b/d.js @@ -27,7 +27,7 @@ exports.D = function() { return string; }; -process.addListener('exit', function() { +process.on('exit', function() { string = 'D done'; }); diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js index 689096c1a8..1e6c6b9598 100644 --- a/test/fixtures/echo.js +++ b/test/fixtures/echo.js @@ -26,10 +26,10 @@ common.print('hello world\r\n'); var stdin = process.openStdin(); -stdin.addListener('data', function(data) { +stdin.on('data', function(data) { process.stdout.write(data.toString()); }); -stdin.addListener('end', function() { +stdin.on('end', function() { process.stdout.end(); }); diff --git a/test/fixtures/net-fd-passing-receiver.js b/test/fixtures/net-fd-passing-receiver.js index 04a143c180..8e0ba14a70 100644 --- a/test/fixtures/net-fd-passing-receiver.js +++ b/test/fixtures/net-fd-passing-receiver.js @@ -26,19 +26,19 @@ path = process.ARGV[2]; greeting = process.ARGV[3]; receiver = net.createServer(function(socket) { - socket.addListener('fd', function(fd) { + socket.on('fd', function(fd) { var peerInfo = process.getpeername(fd); peerInfo.fd = fd; var passedSocket = new net.Socket(peerInfo); - passedSocket.addListener('eof', function() { + passedSocket.on('eof', function() { passedSocket.close(); }); - passedSocket.addListener('data', function(data) { + passedSocket.on('data', function(data) { passedSocket.send('[echo] ' + data); }); - passedSocket.addListener('close', function() { + passedSocket.on('close', function() { receiver.close(); }); passedSocket.send('[greeting] ' + greeting); @@ -46,7 +46,7 @@ receiver = net.createServer(function(socket) { }); /* To signal the test runne we're up and listening */ -receiver.addListener('listening', function() { +receiver.on('listening', function() { common.print('ready'); }); diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js index 8f7b066129..472387815f 100644 --- a/test/fixtures/recvfd.js +++ b/test/fixtures/recvfd.js @@ -51,7 +51,7 @@ function processData(s) { } }; - pipeStream.addListener('drain', drainFunc); + pipeStream.on('drain', drainFunc); pipeStream.resume(); if (pipeStream.write(JSON.stringify(d) + '\n')) { @@ -62,11 +62,11 @@ function processData(s) { // Create a UNIX socket to the path defined by argv[2] and read a file // descriptor and misc data from it. var s = new net.Stream(); -s.addListener('fd', function(fd) { +s.on('fd', function(fd) { receivedFDs.unshift(fd); processData(s); }); -s.addListener('data', function(data) { +s.on('data', function(data) { data.toString('utf8').trim().split('\n').forEach(function(d) { receivedData.unshift(JSON.parse(d)); }); diff --git a/test/fixtures/should_exit.js b/test/fixtures/should_exit.js index 1d80c5210b..fd16817d7c 100644 --- a/test/fixtures/should_exit.js +++ b/test/fixtures/should_exit.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. function tmp() {} -process.addListener('SIGINT', tmp); +process.on('SIGINT', tmp); process.removeListener('SIGINT', tmp); setInterval(function() { process.stdout.write('keep alive\n'); diff --git a/test/fixtures/stdio-filter.js b/test/fixtures/stdio-filter.js index c6daf9aedf..9bb9af59ec 100644 --- a/test/fixtures/stdio-filter.js +++ b/test/fixtures/stdio-filter.js @@ -26,7 +26,7 @@ var replacement = process.argv[3]; var re = new RegExp(regexIn, 'g'); var stdin = process.openStdin(); -stdin.addListener('data', function(data) { +stdin.on('data', function(data) { data = data.toString(); process.stdout.write(data.replace(re, replacement)); }); diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 121cddb01d..0e0375460a 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -36,15 +36,15 @@ function doSpawn(i) { var count = 0; child.stdout.setEncoding('ascii'); - child.stdout.addListener('data', function(chunk) { + child.stdout.on('data', function(chunk) { count += chunk.length; }); - child.stderr.addListener('data', function(chunk) { + child.stderr.on('data', function(chunk) { console.log('stderr: ' + chunk); }); - child.addListener('exit', function() { + child.on('exit', function() { assert.equal(SIZE + 1, count); // + 1 for \n if (i < N) { doSpawn(i + 1); @@ -56,6 +56,6 @@ function doSpawn(i) { doSpawn(0); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(finished); }); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 92b061ff63..3bcf49e902 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -105,7 +105,7 @@ exec('python -c "print 200000*\'C\'"', {maxBuffer: 1000}, assert.ok(/maxBuffer/.test(err.message)); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, success_count); assert.equal(1, error_count); }); diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js index 221a6d251f..6ef2b71f6a 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -41,7 +41,7 @@ var filepathTwo = filenameTwo; var filepathTwoAbs = path.join(testDir, filenameTwo); -process.addListener('exit', function() { +process.on('exit', function() { fs.unlinkSync(filepathOne); fs.unlinkSync(filepathTwoAbs); assert.equal(1, watchSeenOne); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index e26fe09e21..a85cc13bc4 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -36,13 +36,13 @@ var server = net.createServer(function(socket) { server.on('listening', function() { var client = http.createClient(common.PORT); - client.addListener('error', function(err) { + client.on('error', function(err) { // We should receive one error console.log('ERROR! ' + err.message); errorCount++; }); - client.addListener('end', function() { + client.on('end', function() { // When we remove the old Client interface this will most likely have to be // changed. console.log('EOF!'); @@ -51,7 +51,7 @@ server.on('listening', function() { var request = client.request('GET', '/', {'host': 'localhost'}); request.end(); - request.addListener('response', function(response) { + request.on('response', function(response) { console.log('STATUS: ' + response.statusCode); }); }); @@ -63,7 +63,7 @@ setTimeout(function() { }, 500); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, errorCount); assert.equal(1, eofCount); }); diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index e9e3286a4a..4147cbd93c 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -83,7 +83,7 @@ server.listen(common.PORT, function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(true, normalReqSec > 50); assert.equal(true, keepAliveReqSec > 50); assert.equal(true, normalReqSec < keepAliveReqSec); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index a5f7feec08..3f394b8abe 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -37,7 +37,7 @@ for (var i = 0; i < bytes; i++) { } var server = net.createServer(function(c) { - c.addListener('connect', function() { + c.on('connect', function() { total_connections++; common.print('#'); c.write(body); @@ -52,26 +52,26 @@ function runClient(callback) { client.setEncoding('utf8'); - client.addListener('connect', function() { + client.on('connect', function() { common.print('c'); client.recved = ''; client.connections += 1; }); - client.addListener('data', function(chunk) { + client.on('data', function(chunk) { this.recved += chunk; }); - client.addListener('end', function() { + client.on('end', function() { client.end(); }); - client.addListener('error', function(e) { + client.on('error', function(e) { console.log('\n\nERROOOOOr'); throw e; }); - client.addListener('close', function(had_error) { + client.on('close', function(had_error) { common.print('.'); assert.equal(false, had_error); assert.equal(bytes, client.recved.length); @@ -98,7 +98,7 @@ server.listen(common.PORT, function() { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(connections_per_client * concurrency, total_connections); console.log('\nokay!'); }); diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index 0f5577e3cb..740869d219 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -43,7 +43,7 @@ var server = net.createServer(function(connection) { server.on('listening', function() { var client = net.createConnection(common.PORT); client.setEncoding('ascii'); - client.addListener('data', function(d) { + client.on('data', function(d) { common.print(d); recv += d; }); @@ -76,14 +76,14 @@ server.on('listening', function() { }, 500); - client.addListener('end', function() { + client.on('end', function() { server.close(); client.end(); }); }); server.listen(common.PORT); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(N, recv.length); common.debug('Exit'); }); diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index 06d2d34eef..7b1d59036a 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -35,7 +35,7 @@ function pingPongTest(port, host, on_complete) { var server = net.createServer({ allowHalfOpen: true }, function(socket) { socket.setEncoding('utf8'); - socket.addListener('data', function(data) { + socket.on('data', function(data) { console.log(data); assert.equal('PING', data); assert.equal('open', socket.readyState); @@ -46,18 +46,18 @@ function pingPongTest(port, host, on_complete) { }, DELAY); }); - socket.addListener('timeout', function() { + socket.on('timeout', function() { common.debug('server-side timeout!!'); assert.equal(false, true); }); - socket.addListener('end', function() { + socket.on('end', function() { console.log('server-side socket EOF'); assert.equal('writeOnly', socket.readyState); socket.end(); }); - socket.addListener('close', function(had_error) { + socket.on('close', function(had_error) { console.log('server-side socket.end'); assert.equal(false, had_error); assert.equal('closed', socket.readyState); @@ -70,12 +70,12 @@ function pingPongTest(port, host, on_complete) { client.setEncoding('utf8'); - client.addListener('connect', function() { + client.on('connect', function() { assert.equal('open', client.readyState); client.write('PING'); }); - client.addListener('data', function(data) { + client.on('data', function(data) { console.log(data); assert.equal('PONG', data); assert.equal('open', client.readyState); @@ -92,12 +92,12 @@ function pingPongTest(port, host, on_complete) { }, DELAY); }); - client.addListener('timeout', function() { + client.on('timeout', function() { common.debug('client-side timeout!!'); assert.equal(false, true); }); - client.addListener('close', function() { + client.on('close', function() { console.log('client.end'); assert.equal(N + 1, count); assert.ok(client_ended); @@ -109,6 +109,6 @@ function pingPongTest(port, host, on_complete) { pingPongTest(common.PORT); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, tests_run); }); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index d0c9086f90..00245d0061 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -48,7 +48,7 @@ function pingPongTest(port, host, on_complete) { socket.setNoDelay(); socket.timeout = 0; - socket.addListener('data', function(data) { + socket.on('data', function(data) { console.log('server got: ' + JSON.stringify(data)); assert.equal('open', socket.readyState); assert.equal(true, count <= N); @@ -57,12 +57,12 @@ function pingPongTest(port, host, on_complete) { } }); - 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(); @@ -74,12 +74,12 @@ function pingPongTest(port, host, on_complete) { client.setEncoding('utf8'); - client.addListener('connect', function() { + client.on('connect', function() { assert.equal('open', client.readyState); client.write('PING'); }); - client.addListener('data', function(data) { + client.on('data', function(data) { console.log('client got: ' + data); assert.equal('PONG', data); @@ -101,7 +101,7 @@ function pingPongTest(port, host, on_complete) { } }); - client.addListener('close', function() { + client.on('close', function() { assert.equal(N + 1, count); assert.equal(true, sent_final_ping); if (on_complete) on_complete(); @@ -118,6 +118,6 @@ pingPongTest(common.PORT + 1, null); var solaris = /sunos/i.test(process.platform); if (!solaris) pingPongTest(common.PORT + 2, '::1'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(solaris ? 2 : 3, tests_run); }); diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index 50c4fd89cd..923ba2d139 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -39,7 +39,7 @@ for (var i = 0; i < N; i++) { console.log('start server on port ' + common.PORT); var server = net.createServer(function(connection) { - connection.addListener('connect', function() { + connection.on('connect', function() { assert.equal(false, connection.write(body)); console.log('bufferSize: ' + connection.bufferSize); assert.ok(0 <= connection.bufferSize && @@ -52,7 +52,7 @@ server.listen(common.PORT, function() { var paused = false; var client = net.createConnection(common.PORT); client.setEncoding('ascii'); - client.addListener('data', function(d) { + client.on('data', function(d) { chars_recved += d.length; console.log('got ' + chars_recved); if (!paused) { @@ -70,7 +70,7 @@ server.listen(common.PORT, function() { } }); - client.addListener('end', function() { + client.on('end', function() { server.close(); client.end(); }); @@ -78,7 +78,7 @@ server.listen(common.PORT, function() { -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(N, chars_recved); assert.equal(true, npauses > 2); }); diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 8a3bf467b7..4fc43c859f 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -31,24 +31,24 @@ var timeout = 1000; var echo_server = net.createServer(function(socket) { socket.setTimeout(timeout); - socket.addListener('timeout', function() { + socket.on('timeout', function() { console.log('server timeout'); timeouttime = new Date; console.dir(timeouttime); socket.destroy(); }); - socket.addListener('error', function(e) { + socket.on('error', function(e) { throw new Error('Server side socket should not get error. ' + 'We disconnect willingly.'); }); - socket.addListener('data', function(d) { + socket.on('data', function(d) { console.log(d); socket.write(d); }); - socket.addListener('end', function() { + socket.on('end', function() { socket.end(); }); }); @@ -59,12 +59,12 @@ echo_server.listen(common.PORT, function() { var client = net.createConnection(common.PORT); client.setEncoding('UTF8'); client.setTimeout(0); // disable the timeout for client - client.addListener('connect', function() { + client.on('connect', function() { console.log('client connected.'); client.write('hello\r\n'); }); - client.addListener('data', function(chunk) { + client.on('data', function(chunk) { assert.equal('hello\r\n', chunk); if (exchanges++ < 5) { setTimeout(function() { @@ -80,22 +80,22 @@ echo_server.listen(common.PORT, function() { } }); - client.addListener('timeout', function() { + client.on('timeout', function() { throw new Error("client timeout - this shouldn't happen"); }); - client.addListener('end', function() { + client.on('end', function() { console.log('client end'); client.end(); }); - client.addListener('close', function() { + client.on('close', function() { console.log('client disconnect'); echo_server.close(); }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(starttime != null); assert.ok(timeouttime != null); diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index 2ce0c08245..2c45bf05ef 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -120,7 +120,7 @@ var z = setTimeout(t, 200); clearTimeout(y); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(true, setTimeout_called); assert.equal(3, interval_count); assert.equal(11, count4); diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 04a7f13e21..1a3d854101 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -49,6 +49,6 @@ var fd = fs.openSync(f, 'w+'); fs.writeSync(fd, 'xyz\n'); fs.closeSync(fd); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(changes > 0); }); diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js index 4e5655f684..225e3cc3aa 100644 --- a/test/simple/test-child-process-buffering.js +++ b/test/simple/test-child-process-buffering.js @@ -31,12 +31,12 @@ function pwd(callback) { var child = common.spawnPwd(); child.stdout.setEncoding('utf8'); - child.stdout.addListener('data', function(s) { + child.stdout.on('data', function(s) { console.log('stdout: ' + JSON.stringify(s)); output += s; }); - child.addListener('exit', function(c) { + child.on('exit', function(c) { console.log('exit: ' + c); assert.equal(0, c); callback(output); @@ -51,6 +51,6 @@ pwd(function(result) { assert.equal('\n', result[result.length - 1]); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(true, pwd_called); }); diff --git a/test/simple/test-child-process-cwd.js b/test/simple/test-child-process-cwd.js index 7321758e7d..37195ab5d4 100644 --- a/test/simple/test-child-process-cwd.js +++ b/test/simple/test-child-process-cwd.js @@ -39,11 +39,11 @@ function testCwd(options, forCode, forData) { child.stdout.setEncoding('utf8'); - child.stdout.addListener('data', function(chunk) { + child.stdout.on('data', function(chunk) { data += chunk; }); - child.addListener('exit', function(code, signal) { + child.on('exit', function(code, signal) { forData && assert.strictEqual(forData, data.replace(/[\s\r\n]+$/, '')); assert.strictEqual(forCode, code); returns--; @@ -73,6 +73,6 @@ testCwd({cwd: null}, 0); // Check whether all tests actually returned assert.notEqual(0, returns); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(0, returns); }); diff --git a/test/simple/test-child-process-env.js b/test/simple/test-child-process-env.js index d624ee130b..caeb1936c2 100644 --- a/test/simple/test-child-process-env.js +++ b/test/simple/test-child-process-env.js @@ -44,12 +44,12 @@ var response = ''; child.stdout.setEncoding('utf8'); -child.stdout.addListener('data', function(chunk) { +child.stdout.on('data', function(chunk) { console.log('stdout: ' + chunk); response += chunk; }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(response.indexOf('HELLO=WORLD') >= 0); assert.ok(response.indexOf('FOO=BAR') >= 0); }); diff --git a/test/simple/test-child-process-exec-cwd.js b/test/simple/test-child-process-exec-cwd.js index 2751b90781..282faec8ba 100644 --- a/test/simple/test-child-process-exec-cwd.js +++ b/test/simple/test-child-process-exec-cwd.js @@ -50,7 +50,7 @@ var child = exec(pwdcommand, {cwd: dir}, function(err, stdout, stderr) { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, success_count); assert.equal(0, error_count); }); diff --git a/test/simple/test-child-process-exec-env.js b/test/simple/test-child-process-exec-env.js index c82fc069c5..ed0134e5d2 100644 --- a/test/simple/test-child-process-exec-env.js +++ b/test/simple/test-child-process-exec-env.js @@ -50,11 +50,11 @@ if (process.platform !== 'win32') { } child.stdout.setEncoding('utf8'); -child.stdout.addListener('data', function(chunk) { +child.stdout.on('data', function(chunk) { response += chunk; }); -process.addListener('exit', function() { +process.on('exit', function() { console.log('response: ', response); assert.equal(1, success_count); assert.equal(0, error_count); diff --git a/test/simple/test-child-process-exit-code.js b/test/simple/test-child-process-exit-code.js index b86d3e8a1c..c0c25858bb 100644 --- a/test/simple/test-child-process-exit-code.js +++ b/test/simple/test-child-process-exit-code.js @@ -28,7 +28,7 @@ var exits = 0; var exitScript = path.join(common.fixturesDir, 'exit.js'); var exitChild = spawn(process.argv[0], [exitScript, 23]); -exitChild.addListener('exit', function(code, signal) { +exitChild.on('exit', function(code, signal) { assert.strictEqual(code, 23); assert.strictEqual(signal, null); @@ -40,7 +40,7 @@ exitChild.addListener('exit', function(code, signal) { var errorScript = path.join(common.fixturesDir, 'child_process_should_emit_error.js'); var errorChild = spawn(process.argv[0], [errorScript]); -errorChild.addListener('exit', function(code, signal) { +errorChild.on('exit', function(code, signal) { assert.ok(code !== 0); assert.strictEqual(signal, null); @@ -48,6 +48,6 @@ errorChild.addListener('exit', function(code, signal) { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(2, exits); }); diff --git a/test/simple/test-child-process-ipc.js b/test/simple/test-child-process-ipc.js index a3f560cea3..8ccc505a82 100644 --- a/test/simple/test-child-process-ipc.js +++ b/test/simple/test-child-process-ipc.js @@ -33,13 +33,13 @@ var gotEcho = false; var child = spawn(process.argv[0], [sub]); -child.stderr.addListener('data', function(data) { +child.stderr.on('data', function(data) { console.log('parent stderr: ' + data); }); child.stdout.setEncoding('utf8'); -child.stdout.addListener('data', function(data) { +child.stdout.on('data', function(data) { console.log('child said: ' + JSON.stringify(data)); if (!gotHelloWorld) { assert.equal('hello world\r\n', data); @@ -52,12 +52,12 @@ child.stdout.addListener('data', function(data) { } }); -child.stdout.addListener('end', function(data) { +child.stdout.on('end', function(data) { console.log('child end'); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotHelloWorld); assert.ok(gotEcho); }); diff --git a/test/simple/test-child-process-kill.js b/test/simple/test-child-process-kill.js index 0e1d191dff..30b99e20fe 100644 --- a/test/simple/test-child-process-kill.js +++ b/test/simple/test-child-process-kill.js @@ -35,30 +35,30 @@ var gotStderrEOF = false; var cat = spawn('cat'); -cat.stdout.addListener('data', function(chunk) { +cat.stdout.on('data', function(chunk) { assert.ok(false); }); -cat.stdout.addListener('end', function() { +cat.stdout.on('end', function() { gotStdoutEOF = true; }); -cat.stderr.addListener('data', function(chunk) { +cat.stderr.on('data', function(chunk) { assert.ok(false); }); -cat.stderr.addListener('end', function() { +cat.stderr.on('end', function() { gotStderrEOF = true; }); -cat.addListener('exit', function(code, signal) { +cat.on('exit', function(code, signal) { exitCode = code; termSignal = signal; }); cat.kill(); -process.addListener('exit', function() { +process.on('exit', function() { assert.strictEqual(exitCode, null); assert.strictEqual(termSignal, 'SIGTERM'); assert.ok(gotStdoutEOF); diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index 7e05809b78..8e1d18ca48 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -40,35 +40,35 @@ var exitStatus = -1; var gotStdoutEOF = false; cat.stdout.setEncoding('utf8'); -cat.stdout.addListener('data', function(chunk) { +cat.stdout.on('data', function(chunk) { console.log('stdout: ' + chunk); response += chunk; }); -cat.stdout.addListener('end', function() { +cat.stdout.on('end', function() { gotStdoutEOF = true; }); var gotStderrEOF = false; -cat.stderr.addListener('data', function(chunk) { +cat.stderr.on('data', function(chunk) { // shouldn't get any stderr output assert.ok(false); }); -cat.stderr.addListener('end', function(chunk) { +cat.stderr.on('end', function(chunk) { gotStderrEOF = true; }); -cat.addListener('exit', function(status) { +cat.on('exit', function(status) { console.log('exit event'); exitStatus = status; assert.equal('hello world', response); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(0, exitStatus); assert.equal('hello world', response); }); diff --git a/test/simple/test-child-process-stdout-flush.js b/test/simple/test-child-process-stdout-flush.js index b2060005bb..008dcee0ba 100644 --- a/test/simple/test-child-process-stdout-flush.js +++ b/test/simple/test-child-process-stdout-flush.js @@ -35,18 +35,18 @@ var child = spawn(process.argv[0], [sub, n]); var count = 0; child.stderr.setEncoding('utf8'); -child.stderr.addListener('data', function(data) { +child.stderr.on('data', function(data) { console.log('parent stderr: ' + data); assert.ok(false); }); child.stderr.setEncoding('utf8'); -child.stdout.addListener('data', function(data) { +child.stdout.on('data', function(data) { count += data.length; console.log(count); }); -child.addListener('exit', function(data) { +child.on('exit', function(data) { assert.equal(n, count); console.log('okay'); }); diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index 5a028f06d2..8fc8099e3d 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -269,10 +269,10 @@ assert.equal(h1, h2, 'multipled updates'); var fn = path.join(common.fixturesDir, 'sample.png'); var sha1Hash = crypto.createHash('sha1'); var fileStream = fs.createReadStream(fn); -fileStream.addListener('data', function(data) { +fileStream.on('data', function(data) { sha1Hash.update(data); }); -fileStream.addListener('close', function() { +fileStream.on('close', function() { assert.equal(sha1Hash.digest('hex'), '22723e553129a336ad96e10f6aecdf0f45e4149e', 'Test SHA1 of sample.png'); diff --git a/test/simple/test-delayed-require.js b/test/simple/test-delayed-require.js index 2724557b8d..31c324976f 100644 --- a/test/simple/test-delayed-require.js +++ b/test/simple/test-delayed-require.js @@ -27,7 +27,7 @@ setTimeout(function() { a = require('../fixtures/a'); }, 50); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(true, 'A' in a); assert.equal('A', a.A()); assert.equal('D', a.D()); diff --git a/test/simple/test-dgram-pingpong.js b/test/simple/test-dgram-pingpong.js index 4f0360f922..8f6d22fed9 100644 --- a/test/simple/test-dgram-pingpong.js +++ b/test/simple/test-dgram-pingpong.js @@ -60,7 +60,7 @@ function pingPongTest(port, host) { var buf = new Buffer('PING'), client = dgram.createSocket('udp4'); - client.addListener('message', function(msg, rinfo) { + client.on('message', function(msg, rinfo) { console.log('client got: ' + msg + ' from ' + rinfo.address + ':' + rinfo.port); assert.equal('PONG', msg.toString('ascii')); @@ -108,7 +108,7 @@ pingPongTest(20990, 'localhost'); pingPongTest(20988); //pingPongTest('/tmp/pingpong.sock'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(3, tests_run); console.log('done'); }); diff --git a/test/simple/test-eio-race.js b/test/simple/test-eio-race.js index f8ff2c793f..5ec6972cde 100644 --- a/test/simple/test-eio-race.js +++ b/test/simple/test-eio-race.js @@ -80,6 +80,6 @@ fs.open('/dev/zero', 'r', 0666, function(err, fd) { tryToKillEventLoop(); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(pos > 10000); }); diff --git a/test/simple/test-eio-race4.js b/test/simple/test-eio-race4.js index f1204e5850..8eaeda2171 100644 --- a/test/simple/test-eio-race4.js +++ b/test/simple/test-eio-race4.js @@ -37,6 +37,6 @@ for (var i = 0; i < N; i++) { }); } -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(N, j); }); diff --git a/test/simple/test-error-reporting.js b/test/simple/test-error-reporting.js index 3819d3d126..5aa911d412 100644 --- a/test/simple/test-error-reporting.js +++ b/test/simple/test-error-reporting.js @@ -71,6 +71,6 @@ errExec('throws_error3.js', function(err, stdout, stderr) { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(3, exits); }); diff --git a/test/simple/test-eval.js b/test/simple/test-eval.js index da7d1e264c..d33a9ca806 100644 --- a/test/simple/test-eval.js +++ b/test/simple/test-eval.js @@ -43,7 +43,7 @@ var child = exec(cmd, function(err, stdout, stderr) { ++success_count; }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, success_count); assert.equal(0, error_count); }); diff --git a/test/simple/test-event-emitter-add-listeners.js b/test/simple/test-event-emitter-add-listeners.js index 5006bd804f..89afc4362a 100644 --- a/test/simple/test-event-emitter-add-listeners.js +++ b/test/simple/test-event-emitter-add-listeners.js @@ -28,7 +28,7 @@ var e = new events.EventEmitter(); var events_new_listener_emited = []; var times_hello_emited = 0; -e.addListener('newListener', function(event, listener) { +e.on('newListener', function(event, listener) { console.log('newListener: ' + event); events_new_listener_emited.push(event); }); @@ -50,7 +50,7 @@ var f = new events.EventEmitter(); f.setMaxListeners(0); -process.addListener('exit', function() { +process.on('exit', function() { assert.deepEqual(['hello'], events_new_listener_emited); assert.equal(1, times_hello_emited); }); diff --git a/test/simple/test-event-emitter-modify-in-emit.js b/test/simple/test-event-emitter-modify-in-emit.js index 15d350eb44..738af098cd 100644 --- a/test/simple/test-event-emitter-modify-in-emit.js +++ b/test/simple/test-event-emitter-modify-in-emit.js @@ -29,8 +29,8 @@ var e = new events.EventEmitter(); function callback1() { callbacks_called.push('callback1'); - e.addListener('foo', callback2); - e.addListener('foo', callback3); + e.on('foo', callback2); + e.on('foo', callback3); e.removeListener('foo', callback1); } @@ -44,7 +44,7 @@ function callback3() { e.removeListener('foo', callback3); } -e.addListener('foo', callback1); +e.on('foo', callback1); assert.equal(1, e.listeners('foo').length); e.emit('foo'); @@ -59,8 +59,8 @@ e.emit('foo'); assert.equal(0, e.listeners('foo').length); assert.deepEqual(['callback1', 'callback2', 'callback3'], callbacks_called); -e.addListener('foo', callback1); -e.addListener('foo', callback2); +e.on('foo', callback1); +e.on('foo', callback2); assert.equal(2, e.listeners('foo').length); e.removeAllListeners('foo'); assert.equal(0, e.listeners('foo').length); @@ -69,8 +69,8 @@ assert.equal(0, e.listeners('foo').length); // all listeners callbacks_called = []; -e.addListener('foo', callback2); -e.addListener('foo', callback3); +e.on('foo', callback2); +e.on('foo', callback3); assert.equal(2, e.listeners('foo').length); e.emit('foo'); assert.deepEqual(['callback2', 'callback3'], callbacks_called); diff --git a/test/simple/test-event-emitter-num-args.js b/test/simple/test-event-emitter-num-args.js index 375422eb9e..037c56965b 100644 --- a/test/simple/test-event-emitter-num-args.js +++ b/test/simple/test-event-emitter-num-args.js @@ -41,7 +41,7 @@ e.emit('numArgs', null, null, null); e.emit('numArgs', null, null, null, null); e.emit('numArgs', null, null, null, null, null); -process.addListener('exit', function() { +process.on('exit', function() { assert.deepEqual([0, 1, 2, 3, 4, 5], num_args_emited); }); diff --git a/test/simple/test-event-emitter-once.js b/test/simple/test-event-emitter-once.js index 8ab7b6d388..1f0a2075da 100644 --- a/test/simple/test-event-emitter-once.js +++ b/test/simple/test-event-emitter-once.js @@ -43,7 +43,7 @@ e.once('foo', remove); e.removeListener('foo', remove); e.emit('foo'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, times_hello_emited); }); diff --git a/test/simple/test-event-emitter-remove-all-listeners.js b/test/simple/test-event-emitter-remove-all-listeners.js index fa9b57780f..f5676f42b5 100644 --- a/test/simple/test-event-emitter-remove-all-listeners.js +++ b/test/simple/test-event-emitter-remove-all-listeners.js @@ -27,16 +27,16 @@ var events = require('events'); function listener() {} var e1 = new events.EventEmitter(); -e1.addListener('foo', listener); -e1.addListener('bar', listener); +e1.on('foo', listener); +e1.on('bar', listener); e1.removeAllListeners('foo'); assert.deepEqual([], e1.listeners('foo')); assert.deepEqual([listener], e1.listeners('bar')); var e2 = new events.EventEmitter(); -e2.addListener('foo', listener); -e2.addListener('bar', listener); +e2.on('foo', listener); +e2.on('bar', listener); e2.removeAllListeners(); console.error(e2); assert.deepEqual([], e2.listeners('foo')); diff --git a/test/simple/test-event-emitter-remove-listeners.js b/test/simple/test-event-emitter-remove-listeners.js index 0e4b8cb41b..70526668c4 100644 --- a/test/simple/test-event-emitter-remove-listeners.js +++ b/test/simple/test-event-emitter-remove-listeners.js @@ -42,18 +42,18 @@ function listener3() { } var e1 = new events.EventEmitter(); -e1.addListener('hello', listener1); +e1.on('hello', listener1); e1.removeListener('hello', listener1); assert.deepEqual([], e1.listeners('hello')); var e2 = new events.EventEmitter(); -e2.addListener('hello', listener1); +e2.on('hello', listener1); e2.removeListener('hello', listener2); assert.deepEqual([listener1], e2.listeners('hello')); var e3 = new events.EventEmitter(); -e3.addListener('hello', listener1); -e3.addListener('hello', listener2); +e3.on('hello', listener1); +e3.on('hello', listener2); e3.removeListener('hello', listener1); assert.deepEqual([listener2], e3.listeners('hello')); diff --git a/test/simple/test-exception-handler.js b/test/simple/test-exception-handler.js index 294ecafded..38137b8340 100644 --- a/test/simple/test-exception-handler.js +++ b/test/simple/test-exception-handler.js @@ -25,13 +25,13 @@ var assert = require('assert'); var MESSAGE = 'catch me if you can'; var caughtException = false; -process.addListener('uncaughtException', function(e) { +process.on('uncaughtException', function(e) { console.log('uncaught exception! 1'); assert.equal(MESSAGE, e.message); caughtException = true; }); -process.addListener('uncaughtException', function(e) { +process.on('uncaughtException', function(e) { console.log('uncaught exception! 2'); assert.equal(MESSAGE, e.message); caughtException = true; @@ -41,7 +41,7 @@ setTimeout(function() { throw new Error(MESSAGE); }, 10); -process.addListener('exit', function() { +process.on('exit', function() { console.log('exit'); assert.equal(true, caughtException); }); diff --git a/test/simple/test-file-read-noexist.js b/test/simple/test-file-read-noexist.js index 7fad5dd3fa..aa5e761b4f 100644 --- a/test/simple/test-file-read-noexist.js +++ b/test/simple/test-file-read-noexist.js @@ -36,7 +36,7 @@ fs.readFile(filename, 'raw', function(err, content) { } }); -process.addListener('exit', function() { +process.on('exit', function() { console.log('done'); assert.equal(true, got_error); }); diff --git a/test/simple/test-file-write-stream.js b/test/simple/test-file-write-stream.js index b5eb1e4573..5d2286cbd7 100644 --- a/test/simple/test-file-write-stream.js +++ b/test/simple/test-file-write-stream.js @@ -37,14 +37,14 @@ var path = require('path'), }; file - .addListener('open', function(fd) { + .on('open', function(fd) { callbacks.open++; assert.equal('number', typeof fd); }) - .addListener('error', function(err) { + .on('error', function(err) { throw err; }) - .addListener('drain', function() { + .on('drain', function() { callbacks.drain++; if (callbacks.drain == -1) { assert.equal(EXPECTED, fs.readFileSync(fn)); @@ -57,7 +57,7 @@ file }); } }) - .addListener('close', function() { + .on('close', function() { assert.strictEqual(file.bytesWritten, EXPECTED.length * 2); callbacks.close++; @@ -74,7 +74,7 @@ for (var i = 0; i < 11; i++) { })(i); } -process.addListener('exit', function() { +process.on('exit', function() { for (var k in callbacks) { assert.equal(0, callbacks[k], k + ' count off by ' + callbacks[k]); } diff --git a/test/simple/test-fs-chmod.js b/test/simple/test-fs-chmod.js index b1ee4e5c46..c83f5794d6 100644 --- a/test/simple/test-fs-chmod.js +++ b/test/simple/test-fs-chmod.js @@ -91,7 +91,7 @@ fs.open(file, 'a', function(err, fd) { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(2, success_count); assert.equal(false, got_error); }); diff --git a/test/simple/test-fs-error-messages.js b/test/simple/test-fs-error-messages.js index 49f82ceda2..9e61fed3b3 100644 --- a/test/simple/test-fs-error-messages.js +++ b/test/simple/test-fs-error-messages.js @@ -182,7 +182,7 @@ try { assert.ok(0 <= err.message.indexOf(fn)); } -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(expected, errors.length, 'Test fs sync exceptions raised, got ' + errors.length + ' expected ' + expected); diff --git a/test/simple/test-fs-fsync.js b/test/simple/test-fs-fsync.js index c5877ce1d4..e624ed7d65 100644 --- a/test/simple/test-fs-fsync.js +++ b/test/simple/test-fs-fsync.js @@ -54,6 +54,6 @@ fs.open(file, 'a', 0777, function(err, fd) { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(4, successes); }); diff --git a/test/simple/test-fs-open.js b/test/simple/test-fs-open.js index ed87efa070..a0f225e03d 100644 --- a/test/simple/test-fs-open.js +++ b/test/simple/test-fs-open.js @@ -45,7 +45,7 @@ fs.open(__filename, 'r', function(err, fd) { openFd = fd; }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(openFd); }); diff --git a/test/simple/test-fs-read-buffer.js b/test/simple/test-fs-read-buffer.js index ebc3af785d..dc39d6d977 100644 --- a/test/simple/test-fs-read-buffer.js +++ b/test/simple/test-fs-read-buffer.js @@ -45,6 +45,6 @@ var r = fs.readSync(fd, bufferSync, 0, expected.length, 0); assert.deepEqual(bufferSync, new Buffer(expected)); assert.equal(r, expected.length); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(readCalled, 1); }); diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js index 46db1b72ec..069da86839 100644 --- a/test/simple/test-fs-read-stream.js +++ b/test/simple/test-fs-read-stream.js @@ -40,7 +40,7 @@ var paused = false; var file = fs.ReadStream(fn); -file.addListener('open', function(fd) { +file.on('open', function(fd) { file.length = 0; callbacks.open++; assert.equal('number', typeof fd); @@ -53,7 +53,7 @@ file.addListener('open', function(fd) { file.resume(); }); -file.addListener('data', function(data) { +file.on('data', function(data) { assert.ok(data instanceof Buffer); assert.ok(!paused); file.length += data.length; @@ -70,12 +70,12 @@ file.addListener('data', function(data) { }); -file.addListener('end', function(chunk) { +file.on('end', function(chunk) { callbacks.end++; }); -file.addListener('close', function() { +file.on('close', function() { callbacks.close++; assert.ok(!file.readable); @@ -90,7 +90,7 @@ file2.destroy(function(err) { var file3 = fs.createReadStream(fn, {encoding: 'utf8'}); file3.length = 0; -file3.addListener('data', function(data) { +file3.on('data', function(data) { assert.equal('string', typeof(data)); file3.length += data.length; @@ -100,11 +100,11 @@ file3.addListener('data', function(data) { } }); -file3.addListener('close', function() { +file3.on('close', function() { callbacks.close++; }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, callbacks.open); assert.equal(1, callbacks.end); assert.equal(1, callbacks.destroy); @@ -117,19 +117,19 @@ process.addListener('exit', function() { var file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2}); var contentRead = ''; -file4.addListener('data', function(data) { +file4.on('data', function(data) { contentRead += data.toString('utf-8'); }); -file4.addListener('end', function(data) { +file4.on('end', function(data) { assert.equal(contentRead, 'yz'); }); var file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1}); file5.data = ''; -file5.addListener('data', function(data) { +file5.on('data', function(data) { file5.data += data.toString('utf-8'); }); -file5.addListener('end', function() { +file5.on('end', function() { assert.equal(file5.data, 'yz\n'); }); diff --git a/test/simple/test-fs-read.js b/test/simple/test-fs-read.js index 4095815b1c..b41e334d0e 100644 --- a/test/simple/test-fs-read.js +++ b/test/simple/test-fs-read.js @@ -43,6 +43,6 @@ var r = fs.readSync(fd, expected.length, 0, 'utf-8'); assert.equal(r[0], expected); assert.equal(r[1], expected.length); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(readCalled, 1); }); diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js index 0721a1277e..b5f2ed0000 100644 --- a/test/simple/test-fs-realpath.js +++ b/test/simple/test-fs-realpath.js @@ -459,7 +459,7 @@ fs.realpath('/', function(err, result) { -process.addListener('exit', function() { +process.on('exit', function() { unlink.forEach(function(path) { try {fs.unlinkSync(path);} catch (e) {} }); assert.equal(async_completed, async_expected); }); diff --git a/test/simple/test-fs-stat.js b/test/simple/test-fs-stat.js index 8abe07a0e7..6bc8d4ec44 100644 --- a/test/simple/test-fs-stat.js +++ b/test/simple/test-fs-stat.js @@ -114,7 +114,7 @@ fs.stat(__filename, function(err, s) { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(5, success_count); assert.equal(false, got_error); }); diff --git a/test/simple/test-fs-symlink.js b/test/simple/test-fs-symlink.js index a7a780bc55..dba88d115a 100644 --- a/test/simple/test-fs-symlink.js +++ b/test/simple/test-fs-symlink.js @@ -54,7 +54,7 @@ fs.link(srcPath, dstPath, function(err) { completed++; }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(completed, 2); }); diff --git a/test/simple/test-fs-watch.js b/test/simple/test-fs-watch.js index 154bbecbe9..989c6352f3 100644 --- a/test/simple/test-fs-watch.js +++ b/test/simple/test-fs-watch.js @@ -45,7 +45,7 @@ var testsubdir = path.join(testDir, 'testsubdir'); var filepathThree = path.join(testsubdir, filenameThree); -process.addListener('exit', function() { +process.on('exit', function() { fs.unlinkSync(filepathOne); fs.unlinkSync(filepathTwoAbs); fs.unlinkSync(filepathThree); diff --git a/test/simple/test-fs-write-buffer.js b/test/simple/test-fs-write-buffer.js index 3021c3a066..46013bd87b 100644 --- a/test/simple/test-fs-write-buffer.js +++ b/test/simple/test-fs-write-buffer.js @@ -47,7 +47,7 @@ fs.open(filename, 'w', 0644, function(err, fd) { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, openCalled); assert.equal(1, writeCalled); }); diff --git a/test/simple/test-fs-write-file.js b/test/simple/test-fs-write-file.js index b5842c4e3d..7a487bbd51 100644 --- a/test/simple/test-fs-write-file.js +++ b/test/simple/test-fs-write-file.js @@ -91,7 +91,7 @@ fs.writeFile(filename3, n, function(e) { }); -process.addListener('exit', function() { +process.on('exit', function() { common.error('done'); assert.equal(6, ncallbacks); diff --git a/test/simple/test-fs-write-stream.js b/test/simple/test-fs-write-stream.js index 7a257277ec..da75e26f8f 100644 --- a/test/simple/test-fs-write-stream.js +++ b/test/simple/test-fs-write-stream.js @@ -41,7 +41,7 @@ var file = path.join(common.tmpDir, 'write.txt'); (function() { var stream = fs.createWriteStream(file); - stream.addListener('drain', function() { + stream.on('drain', function() { assert.fail('\'drain\' event must not be emitted before ' + 'stream.write() has been called at least once.'); }); diff --git a/test/simple/test-fs-write.js b/test/simple/test-fs-write.js index dbcdbe4838..3d7a357a9a 100644 --- a/test/simple/test-fs-write.js +++ b/test/simple/test-fs-write.js @@ -69,7 +69,7 @@ fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0644, }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(expected, found); assert.equal(expected, found2); }); diff --git a/test/simple/test-http-blank-header.js b/test/simple/test-http-blank-header.js index 4b1282650f..bd9be86102 100644 --- a/test/simple/test-http-blank-header.js +++ b/test/simple/test-http-blank-header.js @@ -42,7 +42,7 @@ var server = http.createServer(function(req, res) { server.listen(common.PORT, function() { var c = net.createConnection(common.PORT); - c.addListener('connect', function() { + c.on('connect', function() { common.error('client wrote message'); c.write('GET /blah HTTP/1.1\r\n' + 'Host: mapdevel.trolologames.ru:443\r\n' + @@ -52,17 +52,17 @@ server.listen(common.PORT, function() { ); }); - c.addListener('end', function() { + c.on('end', function() { c.end(); }); - c.addListener('close', function() { + c.on('close', function() { common.error('client close'); server.close(); }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotReq); }); diff --git a/test/simple/test-http-client-parse-error.js b/test/simple/test-http-client-parse-error.js index b2d0dace7f..1ca7d58f78 100644 --- a/test/simple/test-http-client-parse-error.js +++ b/test/simple/test-http-client-parse-error.js @@ -31,7 +31,7 @@ var srv = net.createServer(function(c) { console.log('connection'); - c.addListener('end', function() { c.end(); }); + c.on('end', function() { c.end(); }); }); var parseError = false; @@ -53,7 +53,7 @@ srv.listen(common.PORT, '127.0.0.1', function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(parseError); }); diff --git a/test/simple/test-http-client-race-2.js b/test/simple/test-http-client-race-2.js index 547ef55d8a..6b7c508c3d 100644 --- a/test/simple/test-http-client-race-2.js +++ b/test/simple/test-http-client-race-2.js @@ -53,7 +53,7 @@ var body1 = ''; var body2 = ''; var body3 = ''; -server.addListener('listening', function() { +server.on('listening', function() { var client = http.createClient(common.PORT); // @@ -61,14 +61,14 @@ server.addListener('listening', function() { // var req1 = client.request('/1'); req1.end(); - req1.addListener('response', function(res1) { + req1.on('response', function(res1) { res1.setEncoding('utf8'); - res1.addListener('data', function(chunk) { + res1.on('data', function(chunk) { body1 += chunk; }); - res1.addListener('end', function() { + res1.on('end', function() { // // Delay execution a little to allow the 'close' event to be processed // (required to trigger this bug!) @@ -87,10 +87,10 @@ server.addListener('listening', function() { // var req2 = client.request('/2'); req2.end(); - req2.addListener('response', function(res2) { + req2.on('response', function(res2) { res2.setEncoding('utf8'); - res2.addListener('data', function(chunk) { body2 += chunk; }); - res2.addListener('end', function() { + res2.on('data', function(chunk) { body2 += chunk; }); + res2.on('end', function() { // // Just to be really sure we've covered all our bases, execute a @@ -98,10 +98,10 @@ server.addListener('listening', function() { // var req3 = client2.request('/3'); req3.end(); - req3.addListener('response', function(res3) { + req3.on('response', function(res3) { res3.setEncoding('utf8'); - res3.addListener('data', function(chunk) { body3 += chunk }); - res3.addListener('end', function() { server.close(); }); + res3.on('data', function(chunk) { body3 += chunk }); + res3.on('end', function() { server.close(); }); }); }); }); @@ -110,7 +110,7 @@ server.addListener('listening', function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(body1_s, body1); assert.equal(body2_s, body2); assert.equal(body3_s, body3); diff --git a/test/simple/test-http-client-race.js b/test/simple/test-http-client-race.js index 9477b63b47..0f50c8e841 100644 --- a/test/simple/test-http-client-race.js +++ b/test/simple/test-http-client-race.js @@ -38,29 +38,29 @@ server.listen(common.PORT); var body1 = ''; var body2 = ''; -server.addListener('listening', function() { +server.on('listening', function() { var req1 = http.request({ port: common.PORT, path: '/1' }); req1.end(); - req1.addListener('response', function(res1) { + req1.on('response', function(res1) { res1.setEncoding('utf8'); - res1.addListener('data', function(chunk) { + res1.on('data', function(chunk) { body1 += chunk; }); - res1.addListener('end', function() { + res1.on('end', function() { var req2 = http.request({ port: common.PORT, path: '/2' }); req2.end(); - req2.addListener('response', function(res2) { + req2.on('response', function(res2) { res2.setEncoding('utf8'); - res2.addListener('data', function(chunk) { body2 += chunk; }); - res2.addListener('end', function() { server.close(); }); + res2.on('data', function(chunk) { body2 += chunk; }); + res2.on('end', function() { server.close(); }); }); }); }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(body1_s, body1); assert.equal(body2_s, body2); }); diff --git a/test/simple/test-http-client-upload-buf.js b/test/simple/test-http-client-upload-buf.js index ecc683a90a..73e07e7f96 100644 --- a/test/simple/test-http-client-upload-buf.js +++ b/test/simple/test-http-client-upload-buf.js @@ -31,11 +31,11 @@ var client_res_complete = false; var server = http.createServer(function(req, res) { assert.equal('POST', req.method); - req.addListener('data', function(chunk) { + req.on('data', function(chunk) { bytesRecieved += chunk.length; }); - req.addListener('end', function() { + req.on('end', function() { server_req_complete = true; console.log('request complete from server'); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -45,17 +45,17 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var req = http.request({ port: common.PORT, method: 'POST', path: '/' }, function(res) { res.setEncoding('utf8'); - res.addListener('data', function(chunk) { + res.on('data', function(chunk) { console.log(chunk); }); - res.addListener('end', function() { + res.on('end', function() { client_res_complete = true; server.close(); }); @@ -67,7 +67,7 @@ server.addListener('listening', function() { common.error('client finished sending request'); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(N, bytesRecieved); assert.equal(true, server_req_complete); assert.equal(true, client_res_complete); diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js index 54ec141602..912ca96084 100644 --- a/test/simple/test-http-client-upload.js +++ b/test/simple/test-http-client-upload.js @@ -31,12 +31,12 @@ var server = http.createServer(function(req, res) { assert.equal('POST', req.method); req.setEncoding('utf8'); - req.addListener('data', function(chunk) { + req.on('data', function(chunk) { console.log('server got: ' + JSON.stringify(chunk)); sent_body += chunk; }); - req.addListener('end', function() { + req.on('end', function() { server_req_complete = true; console.log('request complete from server'); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -46,17 +46,17 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var req = http.request({ port: common.PORT, method: 'POST', path: '/' }, function(res) { res.setEncoding('utf8'); - res.addListener('data', function(chunk) { + res.on('data', function(chunk) { console.log(chunk); }); - res.addListener('end', function() { + res.on('end', function() { client_res_complete = true; server.close(); }); @@ -70,7 +70,7 @@ server.addListener('listening', function() { common.error('client finished sending request'); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal('1\n2\n3\n', sent_body); assert.equal(true, server_req_complete); assert.equal(true, client_res_complete); diff --git a/test/simple/test-http-eof-on-connect.js b/test/simple/test-http-eof-on-connect.js index e6a3150f8e..b52e62fc57 100644 --- a/test/simple/test-http-eof-on-connect.js +++ b/test/simple/test-http-eof-on-connect.js @@ -31,10 +31,10 @@ var http = require('http'); var server = http.createServer(function(req, res) {}); server.listen(common.PORT); -server.addListener('listening', function() { - net.createConnection(common.PORT).addListener('connect', function() { +server.on('listening', function() { + net.createConnection(common.PORT).on('connect', function() { this.destroy(); - }).addListener('close', function() { + }).on('close', function() { server.close(); }); }); diff --git a/test/simple/test-http-exceptions.js b/test/simple/test-http-exceptions.js index 0045b65912..1501d944ae 100644 --- a/test/simple/test-http-exceptions.js +++ b/test/simple/test-http-exceptions.js @@ -39,7 +39,7 @@ server.listen(common.PORT, function() { var exception_count = 0; -process.addListener('uncaughtException', function(err) { +process.on('uncaughtException', function(err) { console.log('Caught an exception: ' + err); if (err.name === 'AssertionError') throw err; if (++exception_count == 4) process.exit(0); diff --git a/test/simple/test-http-expect-continue.js b/test/simple/test-http-expect-continue.js index c6cdf030fa..3c3980a0ac 100644 --- a/test/simple/test-http-expect-continue.js +++ b/test/simple/test-http-expect-continue.js @@ -40,7 +40,7 @@ function handler(req, res) { } var server = http.createServer(handler); -server.addListener('checkContinue', function(req, res) { +server.on('checkContinue', function(req, res) { common.debug('Server got Expect: 100-continue...'); res.writeContinue(); sent_continue = true; @@ -50,7 +50,7 @@ server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var req = http.request({ port: common.PORT, method: 'POST', @@ -60,19 +60,19 @@ server.addListener('listening', function() { common.debug('Client sending request...'); outstanding_reqs++; var body = ''; - req.addListener('continue', function() { + req.on('continue', function() { common.debug('Client got 100 Continue...'); got_continue = true; req.end(test_req_body); }); - req.addListener('response', function(res) { + req.on('response', function(res) { assert.equal(got_continue, true, 'Full response received before 100 Continue'); assert.equal(200, res.statusCode, 'Final status code was ' + res.statusCode + ', not 200.'); res.setEncoding('utf8'); - res.addListener('data', function(chunk) { body += chunk; }); - res.addListener('end', function() { + res.on('data', function(chunk) { body += chunk; }); + res.on('end', function() { common.debug('Got full response.'); assert.equal(body, test_res_body, 'Response body doesn\'t match.'); assert.ok('abcd' in res.headers, 'Response headers missing.'); diff --git a/test/simple/test-http-full-response.js b/test/simple/test-http-full-response.js index cf5956fa1b..6a9638cf67 100644 --- a/test/simple/test-http-full-response.js +++ b/test/simple/test-http-full-response.js @@ -91,6 +91,6 @@ server.listen(common.PORT, function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(3, runs); }); diff --git a/test/simple/test-http-head-request.js b/test/simple/test-http-head-request.js index 016857f799..6b6b876aa6 100644 --- a/test/simple/test-http-head-request.js +++ b/test/simple/test-http-head-request.js @@ -43,7 +43,7 @@ server.listen(common.PORT, function() { path: '/' }, function(response) { common.error('response start'); - response.addListener('end', function() { + response.on('end', function() { common.error('response end'); gotEnd = true; }); @@ -51,6 +51,6 @@ server.listen(common.PORT, function() { request.end(); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotEnd); }); diff --git a/test/simple/test-http-head-response-has-no-body-end.js b/test/simple/test-http-head-response-has-no-body-end.js index 1810f4a2ce..ee48f52743 100644 --- a/test/simple/test-http-head-response-has-no-body-end.js +++ b/test/simple/test-http-head-response-has-no-body-end.js @@ -39,14 +39,14 @@ server.listen(common.PORT); var responseComplete = false; -server.addListener('listening', function() { +server.on('listening', function() { var req = http.request({ port: common.PORT, method: 'HEAD', path: '/' }, function(res) { common.error('response'); - res.addListener('end', function() { + res.on('end', function() { common.error('response end'); server.close(); responseComplete = true; @@ -56,6 +56,6 @@ server.addListener('listening', function() { req.end(); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(responseComplete); }); diff --git a/test/simple/test-http-head-response-has-no-body.js b/test/simple/test-http-head-response-has-no-body.js index 0317071db1..620ad75877 100644 --- a/test/simple/test-http-head-response-has-no-body.js +++ b/test/simple/test-http-head-response-has-no-body.js @@ -36,14 +36,14 @@ server.listen(common.PORT); var responseComplete = false; -server.addListener('listening', function() { +server.on('listening', function() { var req = http.request({ port: common.PORT, method: 'HEAD', path: '/' }, function(res) { common.error('response'); - res.addListener('end', function() { + res.on('end', function() { common.error('response end'); server.close(); responseComplete = true; @@ -53,6 +53,6 @@ server.addListener('listening', function() { req.end(); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(responseComplete); }); diff --git a/test/simple/test-http-keep-alive-close-on-header.js b/test/simple/test-http-keep-alive-close-on-header.js index ddb2bdbeb5..8fd7348dd5 100644 --- a/test/simple/test-http-keep-alive-close-on-header.js +++ b/test/simple/test-http-keep-alive-close-on-header.js @@ -76,7 +76,7 @@ server.listen(common.PORT, function() { port: common.PORT, agent: agent }, function(response) { - response.addListener('end', function() { + response.on('end', function() { assert.equal(1, agent.sockets['localhost:' + common.PORT].length); server.close(); }); @@ -89,6 +89,6 @@ server.listen(common.PORT, function() { request.end(); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(3, connectCount); }); diff --git a/test/simple/test-http-keep-alive.js b/test/simple/test-http-keep-alive.js index 5603a0e011..061747d369 100644 --- a/test/simple/test-http-keep-alive.js +++ b/test/simple/test-http-keep-alive.js @@ -47,7 +47,7 @@ server.listen(common.PORT, function() { }); request.end(); request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function(response) { - response.addListener('end', function() { + response.on('end', function() { assert.equal(1, agent.sockets['localhost:' + common.PORT].length); server.close(); }); diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js index aca2822af8..52165a21d6 100644 --- a/test/simple/test-http-malformed-request.js +++ b/test/simple/test-http-malformed-request.js @@ -42,9 +42,9 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var c = net.createConnection(common.PORT); - c.addListener('connect', function() { + c.on('connect', function() { c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n'); c.end(); }); @@ -52,6 +52,6 @@ server.addListener('listening', function() { // TODO add more! }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(nrequests_expected, nrequests_completed); }); diff --git a/test/simple/test-http-proxy.js b/test/simple/test-http-proxy.js index ce5a6d62b9..099afb9d0a 100644 --- a/test/simple/test-http-proxy.js +++ b/test/simple/test-http-proxy.js @@ -58,11 +58,11 @@ var proxy = http.createServer(function(req, res) { res.writeHead(proxy_res.statusCode, proxy_res.headers); - proxy_res.addListener('data', function(chunk) { + proxy_res.on('data', function(chunk) { res.write(chunk); }); - proxy_res.addListener('end', function() { + proxy_res.on('end', function() { res.end(); common.debug('proxy res'); }); @@ -88,8 +88,8 @@ function startReq() { assert.deepEqual(cookies, res.headers['set-cookie']); res.setEncoding('utf8'); - res.addListener('data', function(chunk) { body += chunk; }); - res.addListener('end', function() { + res.on('data', function(chunk) { body += chunk; }); + res.on('end', function() { proxy.close(); backend.close(); common.debug('closed both'); @@ -104,6 +104,6 @@ proxy.listen(PROXY_PORT, startReq); common.debug('listen backend'); backend.listen(BACKEND_PORT, startReq); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(body, 'hello world\n'); }); diff --git a/test/simple/test-http-response-close.js b/test/simple/test-http-response-close.js index 94b8a9ccfa..a9955d0a45 100644 --- a/test/simple/test-http-response-close.js +++ b/test/simple/test-http-response-close.js @@ -36,7 +36,7 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { console.error('make req'); http.get({ port: common.PORT diff --git a/test/simple/test-http-server.js b/test/simple/test-http-server.js index 4eab19dade..7d97382d3e 100644 --- a/test/simple/test-http-server.js +++ b/test/simple/test-http-server.js @@ -71,17 +71,17 @@ server.listen(common.PORT); server.httpAllowHalfOpen = true; -server.addListener('listening', function() { +server.on('listening', function() { var c = net.createConnection(common.PORT); c.setEncoding('utf8'); - c.addListener('connect', function() { + c.on('connect', function() { c.write('GET /hello?hello=world&foo=b==ar HTTP/1.1\r\n\r\n'); requests_sent += 1; }); - c.addListener('data', function(chunk) { + c.on('data', function(chunk) { server_response += chunk; if (requests_sent == 1) { @@ -105,16 +105,16 @@ 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); diff --git a/test/simple/test-http-set-cookies.js b/test/simple/test-http-set-cookies.js index 13fc8b6eed..bff34d8298 100644 --- a/test/simple/test-http-set-cookies.js +++ b/test/simple/test-http-set-cookies.js @@ -39,7 +39,7 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { // // one set-cookie header // @@ -49,11 +49,11 @@ server.addListener('listening', function() { assert.deepEqual(['A'], res.headers['set-cookie']); assert.equal('text/plain', res.headers['content-type']); - res.addListener('data', function(chunk) { + res.on('data', function(chunk) { console.log(chunk.toString()); }); - res.addListener('end', function() { + res.on('end', function() { if (++nresponses == 2) { server.close(); } @@ -66,11 +66,11 @@ server.addListener('listening', function() { assert.deepEqual(['A', 'B'], res.headers['set-cookie']); assert.equal('text/plain', res.headers['content-type']); - res.addListener('data', function(chunk) { + res.on('data', function(chunk) { console.log(chunk.toString()); }); - res.addListener('end', function() { + res.on('end', function() { if (++nresponses == 2) { server.close(); } @@ -79,6 +79,6 @@ server.addListener('listening', function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(2, nresponses); }); diff --git a/test/simple/test-http-set-timeout.js b/test/simple/test-http-set-timeout.js index 0665aa4b40..1feb946f78 100644 --- a/test/simple/test-http-set-timeout.js +++ b/test/simple/test-http-set-timeout.js @@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) { console.log('got request. setting 1 second timeout'); req.connection.setTimeout(500); - req.connection.addListener('timeout', function() { + req.connection.on('timeout', function() { req.connection.destroy(); common.debug('TIMEOUT'); server.close(); diff --git a/test/simple/test-http-set-trailers.js b/test/simple/test-http-set-trailers.js index 19ad4f0173..a0896df5ac 100644 --- a/test/simple/test-http-set-trailers.js +++ b/test/simple/test-http-set-trailers.js @@ -35,23 +35,23 @@ server.listen(common.PORT); // first, we test an HTTP/1.0 request. -server.addListener('listening', function() { +server.on('listening', function() { var c = net.createConnection(common.PORT); var res_buffer = ''; c.setEncoding('utf8'); - c.addListener('connect', function() { + c.on('connect', function() { outstanding_reqs++; c.write('GET / HTTP/1.0\r\n\r\n'); }); - c.addListener('data', function(chunk) { + c.on('data', function(chunk) { //console.log(chunk); res_buffer += chunk; }); - c.addListener('end', function() { + c.on('end', function() { c.end(); assert.ok(! /x-foo/.test(res_buffer), 'Trailer in HTTP/1.0 response.'); outstanding_reqs--; @@ -63,20 +63,20 @@ server.addListener('listening', function() { }); // now, we test an HTTP/1.1 request. -server.addListener('listening', function() { +server.on('listening', function() { var c = net.createConnection(common.PORT); var res_buffer = ''; var tid; c.setEncoding('utf8'); - c.addListener('connect', function() { + c.on('connect', function() { outstanding_reqs++; c.write('GET / HTTP/1.1\r\n\r\n'); tid = setTimeout(assert.fail, 2000, 'Couldn\'t find last chunk.'); }); - c.addListener('data', function(chunk) { + c.on('data', function(chunk) { //console.log(chunk); res_buffer += chunk; if (/0\r\n/.test(res_buffer)) { // got the end. @@ -95,9 +95,9 @@ server.addListener('listening', function() { }); // now, see if the client sees the trailers. -server.addListener('listening', function() { +server.on('listening', function() { http.get({ port: common.PORT, path: '/hello', headers: {} }, function(res) { - res.addListener('end', function() { + res.on('end', function() { //console.log(res.trailers); assert.ok('x-foo' in res.trailers, 'Client doesn\'t see trailers.'); outstanding_reqs--; diff --git a/test/simple/test-http-upgrade-agent.js b/test/simple/test-http-upgrade-agent.js index d75fb2e6a5..f59633318c 100644 --- a/test/simple/test-http-upgrade-agent.js +++ b/test/simple/test-http-upgrade-agent.js @@ -32,7 +32,7 @@ var net = require('net'); // Create a TCP server var srv = net.createServer(function(c) { var data = ''; - c.addListener('data', function(d) { + c.on('data', function(d) { data += d.toString('utf8'); c.write('HTTP/1.1 101\r\n'); @@ -43,7 +43,7 @@ var srv = net.createServer(function(c) { c.write('nurtzo'); }); - c.addListener('end', function() { + c.on('end', function() { c.end(); }); }); @@ -87,6 +87,6 @@ srv.listen(common.PORT, '127.0.0.1', function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotUpgrade); }); diff --git a/test/simple/test-http-upgrade-client.js b/test/simple/test-http-upgrade-client.js index f7178d9985..3bf5beccf5 100644 --- a/test/simple/test-http-upgrade-client.js +++ b/test/simple/test-http-upgrade-client.js @@ -32,7 +32,7 @@ var net = require('net'); // Create a TCP server var srv = net.createServer(function(c) { var data = ''; - c.addListener('data', function(d) { + c.on('data', function(d) { data += d.toString('utf8'); c.write('HTTP/1.1 101\r\n'); @@ -43,7 +43,7 @@ var srv = net.createServer(function(c) { c.write('nurtzo'); }); - c.addListener('end', function() { + c.on('end', function() { c.end(); }); }); @@ -53,7 +53,7 @@ var gotUpgrade = false; srv.listen(common.PORT, '127.0.0.1', function() { var req = http.get({ port: common.PORT }); - req.addListener('upgrade', function(res, socket, upgradeHead) { + req.on('upgrade', function(res, socket, upgradeHead) { // XXX: This test isn't fantastic, as it assumes that the entire response // from the server will arrive in a single data callback assert.equal(upgradeHead, 'nurtzo'); @@ -71,6 +71,6 @@ srv.listen(common.PORT, '127.0.0.1', function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotUpgrade); }); diff --git a/test/simple/test-http-upgrade-server.js b/test/simple/test-http-upgrade-server.js index 54b0ed26a0..6a14d39aa5 100644 --- a/test/simple/test-http-upgrade-server.js +++ b/test/simple/test-http-upgrade-server.js @@ -39,17 +39,17 @@ function testServer() { var server = this; http.Server.call(server, function() {}); - server.addListener('connection', function() { + server.on('connection', function() { requests_recv++; }); - server.addListener('request', function(req, res) { + server.on('request', function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('okay'); res.end(); }); - server.addListener('upgrade', function(req, socket, upgradeHead) { + server.on('upgrade', function(req, socket, upgradeHead) { socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + 'Upgrade: WebSocket\r\n' + 'Connection: Upgrade\r\n' + @@ -85,7 +85,7 @@ function test_upgrade_with_listener(_server) { conn.setEncoding('utf8'); var state = 0; - conn.addListener('connect', function() { + conn.on('connect', function() { writeReq(conn, 'GET / HTTP/1.1\r\n' + 'Upgrade: WebSocket\r\n' + @@ -94,7 +94,7 @@ function test_upgrade_with_listener(_server) { 'WjN}|M(6'); }); - conn.addListener('data', function(data) { + conn.on('data', function(data) { state++; assert.equal('string', typeof data); @@ -109,7 +109,7 @@ function test_upgrade_with_listener(_server) { } }); - conn.addListener('end', function() { + conn.on('end', function() { assert.equal(2, state); conn.end(); _server.removeAllListeners('upgrade'); @@ -126,7 +126,7 @@ function test_upgrade_no_listener() { var conn = net.createConnection(common.PORT); conn.setEncoding('utf8'); - conn.addListener('connect', function() { + conn.on('connect', function() { writeReq(conn, 'GET / HTTP/1.1\r\n' + 'Upgrade: WebSocket\r\n' + @@ -134,12 +134,12 @@ function test_upgrade_no_listener() { '\r\n'); }); - conn.addListener('end', function() { + conn.on('end', function() { test_upgrade_no_listener_ended = true; conn.end(); }); - conn.addListener('close', function() { + conn.on('close', function() { test_standard_http(); }); } @@ -151,17 +151,17 @@ function test_standard_http() { var conn = net.createConnection(common.PORT); conn.setEncoding('utf8'); - conn.addListener('connect', function() { + conn.on('connect', function() { writeReq(conn, 'GET / HTTP/1.1\r\n\r\n'); }); - conn.addListener('data', function(data) { + conn.on('data', function(data) { assert.equal('string', typeof data); assert.equal('HTTP/1.1 200', data.substr(0, 12)); conn.end(); }); - conn.addListener('close', function() { + conn.on('close', function() { server.close(); }); } @@ -178,7 +178,7 @@ server.listen(common.PORT, function() { /*----------------------------------------------- Fin. -----------------------------------------------*/ -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(3, requests_recv); assert.equal(3, requests_sent); assert.ok(test_upgrade_no_listener_ended); diff --git a/test/simple/test-http-upgrade-server2.js b/test/simple/test-http-upgrade-server2.js index b2d8fbbdf9..e617d3b1c5 100644 --- a/test/simple/test-http-upgrade-server2.js +++ b/test/simple/test-http-upgrade-server2.js @@ -29,7 +29,7 @@ var server = http.createServer(function(req, res) { throw new Error('This shouldn\'t happen.'); }); -server.addListener('upgrade', function(req, socket, upgradeHead) { +server.on('upgrade', function(req, socket, upgradeHead) { common.error('got upgrade event'); // test that throwing an error from upgrade gets // is uncaught @@ -38,7 +38,7 @@ server.addListener('upgrade', function(req, socket, upgradeHead) { var gotError = false; -process.addListener('uncaughtException', function(e) { +process.on('uncaughtException', function(e) { common.error('got \'clientError\' event'); assert.equal('upgrade error', e.message); gotError = true; @@ -49,7 +49,7 @@ process.addListener('uncaughtException', function(e) { server.listen(common.PORT, function() { var c = net.createConnection(common.PORT); - c.addListener('connect', function() { + c.on('connect', function() { common.error('client wrote message'); c.write('GET /blah HTTP/1.1\r\n' + 'Upgrade: WebSocket\r\n' + @@ -57,16 +57,16 @@ server.listen(common.PORT, function() { '\r\n\r\nhello world'); }); - c.addListener('end', function() { + c.on('end', function() { c.end(); }); - c.addListener('close', function() { + c.on('close', function() { common.error('client close'); server.close(); }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(gotError); }); diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js index d68cbdc12d..b6cf7d8be4 100644 --- a/test/simple/test-http-wget.js +++ b/test/simple/test-http-wget.js @@ -51,35 +51,35 @@ var server = http.createServer(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var c = net.createConnection(common.PORT); c.setEncoding('utf8'); - c.addListener('connect', function() { + c.on('connect', function() { c.write('GET / HTTP/1.0\r\n' + 'Connection: Keep-Alive\r\n\r\n'); }); - c.addListener('data', function(chunk) { + c.on('data', function(chunk) { console.log(chunk); server_response += chunk; }); - c.addListener('end', function() { + c.on('end', function() { client_got_eof = true; console.log('got end'); c.end(); }); - c.addListener('close', function() { + c.on('close', function() { connection_was_closed = true; console.log('got close'); server.close(); }); }); -process.addListener('exit', function() { +process.on('exit', function() { var m = server_response.split('\r\n\r\n'); assert.equal(m[1], 'hello world\n'); assert.ok(client_got_eof); diff --git a/test/simple/test-http-write-empty-string.js b/test/simple/test-http-write-empty-string.js index 2bee46d6cb..baf9c27f4b 100644 --- a/test/simple/test-http-write-empty-string.js +++ b/test/simple/test-http-write-empty-string.js @@ -39,7 +39,7 @@ var server = http.createServer(function(request, response) { var response = ''; -process.addListener('exit', function() { +process.on('exit', function() { assert.equal('1\n2\n3\n', response); }); @@ -48,7 +48,7 @@ server.listen(common.PORT, function() { http.get({ port: common.PORT }, function(res) { assert.equal(200, res.statusCode); res.setEncoding('ascii'); - res.addListener('data', function(chunk) { + res.on('data', function(chunk) { response += chunk; }); common.error('Got /hello response'); diff --git a/test/simple/test-http.js b/test/simple/test-http.js index 3c3fd05cc6..1915e24630 100644 --- a/test/simple/test-http.js +++ b/test/simple/test-http.js @@ -52,7 +52,7 @@ var server = http.Server(function(req, res) { this.close(); } - req.addListener('end', function() { + req.on('end', function() { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('The path was ' + url.parse(req.url).pathname); res.end(); @@ -63,7 +63,7 @@ var server = http.Server(function(req, res) { }); server.listen(common.PORT); -server.addListener('listening', function() { +server.on('listening', function() { var agent = new http.Agent({ port: common.PORT, maxSockets: 1 }); http.get({ port: common.PORT, @@ -74,7 +74,7 @@ server.addListener('listening', function() { assert.equal(200, res.statusCode); responses_recvd += 1; res.setEncoding('utf8'); - res.addListener('data', function(chunk) { body0 += chunk; }); + res.on('data', function(chunk) { body0 += chunk; }); common.debug('Got /hello response'); }); @@ -88,14 +88,14 @@ server.addListener('listening', function() { assert.equal(200, res.statusCode); responses_recvd += 1; res.setEncoding('utf8'); - res.addListener('data', function(chunk) { body1 += chunk; }); + res.on('data', function(chunk) { body1 += chunk; }); common.debug('Got /world response'); }); req.end(); }, 1); }); -process.addListener('exit', function() { +process.on('exit', function() { common.debug('responses_recvd: ' + responses_recvd); assert.equal(2, responses_recvd); diff --git a/test/simple/test-mkdir-rmdir.js b/test/simple/test-mkdir-rmdir.js index 023d4d4976..73534555c8 100644 --- a/test/simple/test-mkdir-rmdir.js +++ b/test/simple/test-mkdir-rmdir.js @@ -54,7 +54,7 @@ fs.mkdir(d, 0666, function(err) { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(false, mkdir_error); assert.equal(false, rmdir_error); console.log('exit'); diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js index d6af3b157c..3e590ea414 100644 --- a/test/simple/test-module-loading.js +++ b/test/simple/test-module-loading.js @@ -206,7 +206,7 @@ assert.deepEqual(json, { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(common.indirectInstanceOf(a.A, Function)); assert.equal('A done', a.A()); diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js index 80f9eea0ec..349e2da000 100644 --- a/test/simple/test-net-binary.js +++ b/test/simple/test-net-binary.js @@ -42,11 +42,11 @@ for (var i = 255; i >= 0; i--) { // safe constructor var echoServer = net.Server(function(connection) { connection.setEncoding('binary'); - connection.addListener('data', function(chunk) { + connection.on('data', function(chunk) { common.error('recved: ' + JSON.stringify(chunk)); connection.write(chunk, 'binary'); }); - connection.addListener('end', function() { + connection.on('end', function() { connection.end(); }); }); @@ -54,12 +54,12 @@ echoServer.listen(common.PORT); var recv = ''; -echoServer.addListener('listening', function() { +echoServer.on('listening', function() { var j = 0; var c = net.createConnection(common.PORT); c.setEncoding('binary'); - c.addListener('data', function(chunk) { + c.on('data', function(chunk) { if (j < 256) { common.error('write ' + j); c.write(String.fromCharCode(j), 'binary'); @@ -70,17 +70,17 @@ echoServer.addListener('listening', function() { recv += chunk; }); - c.addListener('connect', function() { + c.on('connect', function() { c.write(binaryString, 'binary'); }); - c.addListener('close', function() { + c.on('close', function() { console.dir(recv); echoServer.close(); }); }); -process.addListener('exit', function() { +process.on('exit', function() { console.log('recv: ' + JSON.stringify(recv)); assert.equal(2 * 256, recv.length); diff --git a/test/simple/test-net-eaddrinuse.js b/test/simple/test-net-eaddrinuse.js index aa3666a189..2192ea2242 100644 --- a/test/simple/test-net-eaddrinuse.js +++ b/test/simple/test-net-eaddrinuse.js @@ -28,7 +28,7 @@ var server1 = net.createServer(function(socket) { var server2 = net.createServer(function(socket) { }); server1.listen(common.PORT); -server2.addListener('error', function(error) { +server2.on('error', function(error) { assert.equal(true, error.message.indexOf('EADDRINUSE') >= 0); server1.close(); }); diff --git a/test/simple/test-net-keepalive.js b/test/simple/test-net-keepalive.js index 4da5efce2e..b09d9d5d68 100644 --- a/test/simple/test-net-keepalive.js +++ b/test/simple/test-net-keepalive.js @@ -30,13 +30,13 @@ var echoServer = net.createServer(function(connection) { assert.notEqual(connection.setKeepAlive, undefined); // send a keepalive packet after 1000 ms connection.setKeepAlive(true, 1000); - connection.addListener('end', function() { + connection.on('end', function() { connection.end(); }); }); echoServer.listen(common.PORT); -echoServer.addListener('listening', function() { +echoServer.on('listening', function() { var clientConnection = net.createConnection(common.PORT); clientConnection.setTimeout(0); diff --git a/test/simple/test-net-pingpong.js b/test/simple/test-net-pingpong.js index 4f512c449f..a81f0dc80d 100644 --- a/test/simple/test-net-pingpong.js +++ b/test/simple/test-net-pingpong.js @@ -41,7 +41,7 @@ function pingPongTest(port, host) { socket.timeout = 0; socket.setEncoding('utf8'); - socket.addListener('data', function(data) { + socket.on('data', function(data) { // Since we never queue data (we're always waiting for the PING // before sending a pong) the writeQueueSize should always be less // than one message. @@ -59,17 +59,17 @@ function pingPongTest(port, host) { } }); - socket.addListener('end', function() { + socket.on('end', function() { assert.equal(true, socket.writable); // because allowHalfOpen assert.equal(false, socket.readable); socket.end(); }); - socket.addListener('error', function(e) { + socket.on('error', function(e) { throw e; }); - socket.addListener('close', function() { + socket.on('close', function() { console.log('server socket.endd'); assert.equal(false, socket.writable); assert.equal(false, socket.readable); @@ -84,13 +84,13 @@ function pingPongTest(port, host) { var client = net.createConnection(port, host); client.setEncoding('ascii'); - client.addListener('connect', function() { + client.on('connect', function() { assert.equal(true, client.readable); assert.equal(true, client.writable); client.write('PING'); }); - client.addListener('data', function(data) { + client.on('data', function(data) { console.log('client got: ' + data); assert.equal('PONG', data); @@ -114,7 +114,7 @@ function pingPongTest(port, host) { } }); - client.addListener('close', function() { + client.on('close', function() { console.log('client.end'); assert.equal(N + 1, count); assert.equal(N + 1, sentPongs); @@ -122,7 +122,7 @@ function pingPongTest(port, host) { tests_run += 1; }); - client.addListener('error', function(e) { + client.on('error', function(e) { throw e; }); }); @@ -134,7 +134,7 @@ pingPongTest(20988); pingPongTest(20989, 'localhost'); pingPongTest(20997, '::1'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(4, tests_run); console.log('done'); }); diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js index 8455f1689e..f7fcb8b29b 100644 --- a/test/simple/test-net-reconnect.js +++ b/test/simple/test-net-reconnect.js @@ -30,15 +30,15 @@ var client_recv_count = 0; var disconnect_count = 0; var server = net.createServer(function(socket) { - socket.addListener('connect', function() { + socket.on('connect', function() { socket.write('hello\r\n'); }); - socket.addListener('end', function() { + socket.on('end', function() { socket.end(); }); - socket.addListener('close', function(had_error) { + socket.on('close', function(had_error) { //console.log('server had_error: ' + JSON.stringify(had_error)); assert.equal(false, had_error); }); @@ -50,18 +50,18 @@ server.listen(common.PORT, function() { client.setEncoding('UTF8'); - client.addListener('connect', function() { + client.on('connect', function() { console.log('client connected.'); }); - client.addListener('data', function(chunk) { + client.on('data', function(chunk) { client_recv_count += 1; console.log('client_recv_count ' + client_recv_count); assert.equal('hello\r\n', chunk); client.end(); }); - client.addListener('close', function(had_error) { + client.on('close', function(had_error) { console.log('disconnect'); assert.equal(false, had_error); if (disconnect_count++ < N) @@ -71,7 +71,7 @@ server.listen(common.PORT, function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(N + 1, disconnect_count); assert.equal(N + 1, client_recv_count); }); diff --git a/test/simple/test-next-tick-errors.js b/test/simple/test-next-tick-errors.js index ea895fd068..bf3c2e3065 100644 --- a/test/simple/test-next-tick-errors.js +++ b/test/simple/test-next-tick-errors.js @@ -40,7 +40,7 @@ process.nextTick(function() { order.push('C'); }); -process.addListener('uncaughtException', function() { +process.on('uncaughtException', function() { if (!exceptionHandled) { exceptionHandled = true; order.push('B'); @@ -51,7 +51,7 @@ process.addListener('uncaughtException', function() { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.deepEqual(['A', 'B', 'C'], order); }); diff --git a/test/simple/test-next-tick-ordering.js b/test/simple/test-next-tick-ordering.js index f392bb29b7..5dc1dfbe16 100644 --- a/test/simple/test-next-tick-ordering.js +++ b/test/simple/test-next-tick-ordering.js @@ -45,7 +45,7 @@ for (i = 0; i < N; i += 1) { console.log('Running from main.'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal('nextTick', done[0]); /* Disabling this test. I don't think we can ensure the order for (i = 0; i < N; i += 1) { diff --git a/test/simple/test-next-tick-ordering2.js b/test/simple/test-next-tick-ordering2.js index c845b98683..94fd20fbb5 100644 --- a/test/simple/test-next-tick-ordering2.js +++ b/test/simple/test-next-tick-ordering2.js @@ -33,6 +33,6 @@ process.nextTick(function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.deepEqual(order, ['nextTick', 'setTimeout']); }); diff --git a/test/simple/test-next-tick.js b/test/simple/test-next-tick.js index 1c9a51d0e0..894729cc6f 100644 --- a/test/simple/test-next-tick.js +++ b/test/simple/test-next-tick.js @@ -45,6 +45,6 @@ process.nextTick(function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(5, complete); }); diff --git a/test/simple/test-pipe-head.js b/test/simple/test-pipe-head.js index 88552006a0..eaba8bb2c4 100644 --- a/test/simple/test-pipe-head.js +++ b/test/simple/test-pipe-head.js @@ -43,6 +43,6 @@ exec(cmd, function(err, stdout, stderr) { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(finished); }); diff --git a/test/simple/test-pump-file2tcp-noexist.js b/test/simple/test-pump-file2tcp-noexist.js index 642849018a..8017db73f1 100644 --- a/test/simple/test-pump-file2tcp-noexist.js +++ b/test/simple/test-pump-file2tcp-noexist.js @@ -48,16 +48,16 @@ var server = net.createServer(function(stream) { server.listen(common.PORT, function() { var conn = net.createConnection(common.PORT); conn.setEncoding('utf8'); - conn.addListener('data', function(chunk) { + conn.on('data', function(chunk) { common.error('recv data! nchars = ' + chunk.length); buffer += chunk; }); - conn.addListener('end', function() { + conn.on('end', function() { conn.end(); }); - conn.addListener('close', function() { + conn.on('close', function() { common.error('client connection close'); conn_closed = true; }); @@ -65,7 +65,7 @@ server.listen(common.PORT, function() { var buffer = ''; -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(true, got_error); assert.equal(true, conn_closed); console.log('exiting'); diff --git a/test/simple/test-pump-file2tcp.js b/test/simple/test-pump-file2tcp.js index b9250cc03f..60c0fdd7f0 100644 --- a/test/simple/test-pump-file2tcp.js +++ b/test/simple/test-pump-file2tcp.js @@ -41,15 +41,15 @@ var server = net.createServer(function(stream) { server.listen(common.PORT, function() { var conn = net.createConnection(common.PORT); conn.setEncoding('utf8'); - conn.addListener('data', function(chunk) { + conn.on('data', function(chunk) { common.error('recv data! nchars = ' + chunk.length); buffer += chunk; }); - conn.addListener('end', function() { + conn.on('end', function() { conn.end(); }); - conn.addListener('close', function() { + conn.on('close', function() { common.error('client connection close'); }); }); @@ -57,9 +57,9 @@ server.listen(common.PORT, function() { var buffer = ''; var count = 0; -server.addListener('listening', function() { +server.on('listening', function() { }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(expected, buffer); }); diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js index b27807a10a..10ba75bab6 100644 --- a/test/simple/test-readdir.js +++ b/test/simple/test-readdir.js @@ -54,7 +54,7 @@ fs.readdir(readdirDir, function(err, f) { } }); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(false, got_error); console.log('exit'); }); diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index c9ccbf71a8..783c3ab493 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -68,7 +68,7 @@ function error_test() { var read_buffer = ''; client_unix.removeAllListeners('data'); - client_unix.addListener('data', function(data) { + client_unix.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); common.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' + (client_unix.expect.exec ? @@ -145,7 +145,7 @@ function tcp_test() { server_tcp = net.createServer(function(socket) { assert.strictEqual(server_tcp, socket.server); - socket.addListener('end', function() { + socket.on('end', function() { socket.end(); }); @@ -157,7 +157,7 @@ function tcp_test() { client_tcp = net.createConnection(common.PORT); - client_tcp.addListener('connect', function() { + client_tcp.on('connect', function() { assert.equal(true, client_tcp.readable); assert.equal(true, client_tcp.writable); @@ -174,7 +174,7 @@ function tcp_test() { ]); }); - client_tcp.addListener('data', function(data) { + client_tcp.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); common.error('TCP data: ' + JSON.stringify(read_buffer) + ', expecting ' + JSON.stringify(client_tcp.expect)); @@ -193,11 +193,11 @@ function tcp_test() { } }); - client_tcp.addListener('error', function(e) { + client_tcp.on('error', function(e) { throw e; }); - client_tcp.addListener('close', function() { + client_tcp.on('close', function() { server_tcp.close(); }); }); @@ -208,19 +208,19 @@ function unix_test() { server_unix = net.createServer(function(socket) { assert.strictEqual(server_unix, socket.server); - socket.addListener('end', function() { + socket.on('end', function() { socket.end(); }); repl.start(prompt_unix, socket).context.message = message; }); - server_unix.addListener('listening', function() { + server_unix.on('listening', function() { var read_buffer = ''; client_unix = net.createConnection(common.PIPE); - client_unix.addListener('connect', function() { + client_unix.on('connect', function() { assert.equal(true, client_unix.readable); assert.equal(true, client_unix.writable); @@ -238,7 +238,7 @@ function unix_test() { ]); }); - client_unix.addListener('data', function(data) { + client_unix.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); common.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' + JSON.stringify(client_unix.expect)); @@ -257,11 +257,11 @@ function unix_test() { } }); - client_unix.addListener('error', function(e) { + client_unix.on('error', function(e) { throw e; }); - client_unix.addListener('close', function() { + client_unix.on('close', function() { server_unix.close(); }); }); diff --git a/test/simple/test-signal-handler.js b/test/simple/test-signal-handler.js index 47f303c273..290dcf0b00 100644 --- a/test/simple/test-signal-handler.js +++ b/test/simple/test-signal-handler.js @@ -32,12 +32,12 @@ var first = 0, var sighup = false; -process.addListener('SIGUSR1', function() { +process.on('SIGUSR1', function() { console.log('Interrupted by SIGUSR1'); first += 1; }); -process.addListener('SIGUSR1', function() { +process.on('SIGUSR1', function() { second += 1; setTimeout(function() { console.log('End.'); @@ -54,14 +54,14 @@ setInterval(function() { } }, 1); -// Test addListener condition where a watcher for SIGNAL +// Test on condition where a watcher for SIGNAL // has been previously registered, and `process.listeners(SIGNAL).length === 1` -process.addListener('SIGHUP', function() {}); +process.on('SIGHUP', function() {}); process.removeAllListeners('SIGHUP'); -process.addListener('SIGHUP', function() { sighup = true }); +process.on('SIGHUP', function() { sighup = true }); process.kill(process.pid, 'SIGHUP'); -process.addListener('exit', function() { +process.on('exit', function() { assert.equal(1, first); assert.equal(1, second); assert.equal(true, sighup); diff --git a/test/simple/test-signal-unregister.js b/test/simple/test-signal-unregister.js index 80b308ab8d..9e669f42a0 100644 --- a/test/simple/test-signal-unregister.js +++ b/test/simple/test-signal-unregister.js @@ -33,7 +33,7 @@ var childKilled = false, done = false, var join = require('path').join; child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]); -child.addListener('exit', function() { +child.on('exit', function() { if (!done) childKilled = true; }); @@ -51,6 +51,6 @@ setTimeout(function() { }, 200); }, 200); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(childKilled); }); diff --git a/test/simple/test-stdout-to-file.js b/test/simple/test-stdout-to-file.js index 4a5a2ecb87..199cbc3193 100644 --- a/test/simple/test-stdout-to-file.js +++ b/test/simple/test-stdout-to-file.js @@ -72,6 +72,6 @@ test(1024 * 1024, false, function() { }); }); -process.addListener('exit', function() { +process.on('exit', function() { assert.ok(finished); });