★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/24481/filesNouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: replace anonymous closure with arrow functions #24481

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+9 −9
Diff settings

Always

Just for now

Copy path View file
@@ -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();
@@ -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');
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.