test: replace callback with arrow functions
PR-URL: https://github.com/nodejs/node/pull/24541 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
d45e303ac6
commit
c90b514275
@ -34,7 +34,7 @@ const body = 'C'.repeat(N);
|
||||
|
||||
console.log(`start server on port ${common.PORT}`);
|
||||
|
||||
const server = net.createServer(function(connection) {
|
||||
const server = net.createServer((connection) => {
|
||||
connection.write(body.slice(0, part_N));
|
||||
connection.write(body.slice(part_N, 2 * part_N));
|
||||
assert.strictEqual(connection.write(body.slice(2 * part_N, N)), false);
|
||||
@ -44,11 +44,11 @@ const server = net.createServer(function(connection) {
|
||||
connection.end();
|
||||
});
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
server.listen(common.PORT, () => {
|
||||
let paused = false;
|
||||
const client = net.createConnection(common.PORT);
|
||||
client.setEncoding('ascii');
|
||||
client.on('data', function(d) {
|
||||
client.on('data', (d) => {
|
||||
chars_recved += d.length;
|
||||
console.log(`got ${chars_recved}`);
|
||||
if (!paused) {
|
||||
@ -57,7 +57,7 @@ server.listen(common.PORT, function() {
|
||||
paused = true;
|
||||
console.log('pause');
|
||||
const x = chars_recved;
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
assert.strictEqual(chars_recved, x);
|
||||
client.resume();
|
||||
console.log('resume');
|
||||
@ -66,14 +66,14 @@ server.listen(common.PORT, function() {
|
||||
}
|
||||
});
|
||||
|
||||
client.on('end', function() {
|
||||
client.on('end', () => {
|
||||
server.close();
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
process.on('exit', () => {
|
||||
assert.strictEqual(chars_recved, N);
|
||||
assert.strictEqual(npauses > 2, true);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user