test: replace anonymous closure with arrow functions
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
0759b57d7e
commit
0bf743a8a5
@ -28,13 +28,13 @@ const N = 200;
|
|||||||
let recv = '';
|
let recv = '';
|
||||||
let chars_recved = 0;
|
let chars_recved = 0;
|
||||||
|
|
||||||
const server = net.createServer(function(connection) {
|
const server = net.createServer((connection) => {
|
||||||
function write(j) {
|
function write(j) {
|
||||||
if (j >= N) {
|
if (j >= N) {
|
||||||
connection.end();
|
connection.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
connection.write('C');
|
connection.write('C');
|
||||||
write(j + 1);
|
write(j + 1);
|
||||||
}, 10);
|
}, 10);
|
||||||
@ -42,7 +42,7 @@ const server = net.createServer(function(connection) {
|
|||||||
write(0);
|
write(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on('listening', function() {
|
server.on('listening', () => {
|
||||||
const client = net.createConnection(common.PORT);
|
const client = net.createConnection(common.PORT);
|
||||||
client.setEncoding('ascii');
|
client.setEncoding('ascii');
|
||||||
client.on('data', function(d) {
|
client.on('data', function(d) {
|
||||||
@ -50,22 +50,22 @@ server.on('listening', function() {
|
|||||||
recv += d;
|
recv += d;
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
chars_recved = recv.length;
|
chars_recved = recv.length;
|
||||||
console.log(`pause at: ${chars_recved}`);
|
console.log(`pause at: ${chars_recved}`);
|
||||||
assert.strictEqual(chars_recved > 1, true);
|
assert.strictEqual(chars_recved > 1, true);
|
||||||
client.pause();
|
client.pause();
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
console.log(`resume at: ${chars_recved}`);
|
console.log(`resume at: ${chars_recved}`);
|
||||||
assert.strictEqual(chars_recved, recv.length);
|
assert.strictEqual(chars_recved, recv.length);
|
||||||
client.resume();
|
client.resume();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
chars_recved = recv.length;
|
chars_recved = recv.length;
|
||||||
console.log(`pause at: ${chars_recved}`);
|
console.log(`pause at: ${chars_recved}`);
|
||||||
client.pause();
|
client.pause();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
console.log(`resume at: ${chars_recved}`);
|
console.log(`resume at: ${chars_recved}`);
|
||||||
assert.strictEqual(chars_recved, recv.length);
|
assert.strictEqual(chars_recved, recv.length);
|
||||||
client.resume();
|
client.resume();
|
||||||
@ -78,14 +78,14 @@ server.on('listening', function() {
|
|||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
client.on('end', function() {
|
client.on('end', () => {
|
||||||
server.close();
|
server.close();
|
||||||
client.end();
|
client.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
server.listen(common.PORT);
|
server.listen(common.PORT);
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
assert.strictEqual(recv.length, N);
|
assert.strictEqual(recv.length, N);
|
||||||
console.error('Exit');
|
console.error('Exit');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user