Skip to content

Commit

Permalink
doc: document and test that methods return this
Browse files Browse the repository at this point in the history
Also, add tests to ensure they will always return this, and to confirm
they return this when these doc changes are back-ported to earlier
release lines.

PR-URL: #13553
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
sam-github authored and MylesBorins committed Jul 18, 2017
1 parent 34fc7a0 commit 2fb1381
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-net-end-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const s = new net.Socket({
},
writable: false
});
s.resume();
assert.strictEqual(s, s.resume());

const events = [];

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-net-server-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let server = net.createServer(function(c) {
sockets.push(c);

if (sockets.length === 2) {
server.close();
assert.strictEqual(server.close(), server);
sockets.forEach(function(c) { c.destroy(); });
}
});
Expand All @@ -32,7 +32,7 @@ server.on('close', function() {
events.push('server');
});

server.listen(0, function() {
assert.strictEqual(server, server.listen(0, function() {
net.createConnection(this.address().port);
net.createConnection(this.address().port);
});
}));
9 changes: 6 additions & 3 deletions test/parallel/test-net-socket-local-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ function connect() {

conns++;
client.once('close', connect);
client.connect(server.address().port, common.localhostIPv4, () => {
clientLocalPorts.push(client.localPort);
});
assert.strictEqual(
client,
client.connect(server.address().port, common.localhostIPv4, () => {
clientLocalPorts.push(client.localPort);
})
);
}
2 changes: 1 addition & 1 deletion test/parallel/test-net-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const server = net.createServer(function(socket) {
}).listen(0, function() {
const conn = net.connect(this.address().port);
conn.on('data', function(buf) {
conn.pause();
assert.strictEqual(conn, conn.pause());
setTimeout(function() {
conn.destroy();
}, 20);
Expand Down

0 comments on commit 2fb1381

Please sign in to comment.