Skip to content

Commit

Permalink
test: replace anonymous closure with arrow functions
Browse files Browse the repository at this point in the history
PR-URL: #24481
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
suman-mitra authored and codebytere committed Jan 29, 2019
1 parent b1bbedd commit d245f53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/pummel/test-net-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,44 @@ const N = 200;
let recv = '';
let chars_recved = 0;

const server = net.createServer(function(connection) {
const server = net.createServer((connection) => {
function write(j) {
if (j >= N) {
connection.end();
return;
}
setTimeout(function() {
setTimeout(() => {
connection.write('C');
write(j + 1);
}, 10);
}
write(0);
});

server.on('listening', function() {
server.on('listening', () => {
const client = net.createConnection(common.PORT);
client.setEncoding('ascii');
client.on('data', function(d) {
console.log(d);
recv += d;
});

setTimeout(function() {
setTimeout(() => {
chars_recved = recv.length;
console.log(`pause at: ${chars_recved}`);
assert.strictEqual(chars_recved > 1, true);
client.pause();
setTimeout(function() {
setTimeout(() => {
console.log(`resume at: ${chars_recved}`);
assert.strictEqual(chars_recved, recv.length);
client.resume();

setTimeout(function() {
setTimeout(() => {
chars_recved = recv.length;
console.log(`pause at: ${chars_recved}`);
client.pause();

setTimeout(function() {
setTimeout(() => {
console.log(`resume at: ${chars_recved}`);
assert.strictEqual(chars_recved, recv.length);
client.resume();
Expand All @@ -78,14 +78,14 @@ server.on('listening', function() {

}, 500);

client.on('end', function() {
client.on('end', () => {
server.close();
client.end();
});
});
server.listen(common.PORT);

process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(recv.length, N);
console.error('Exit');
});

0 comments on commit d245f53

Please sign in to comment.