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 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);
|
||||
@ -42,7 +42,7 @@ const server = net.createServer(function(connection) {
|
||||
write(0);
|
||||
});
|
||||
|
||||
server.on('listening', function() {
|
||||
server.on('listening', () => {
|
||||
const client = net.createConnection(common.PORT);
|
||||
client.setEncoding('ascii');
|
||||
client.on('data', function(d) {
|
||||
@ -50,22 +50,22 @@ server.on('listening', function() {
|
||||
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();
|
||||
@ -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');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user