Skip to content

Commit

Permalink
test: improve test-net-socket-timeout
Browse files Browse the repository at this point in the history
* Check for custom Node.js code rather than constructor in
  assert.throws().
* Use arrow functions consistently.

PR-URL: #24859
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
Trott authored and BethGriggs committed Feb 20, 2019
1 parent d972f28 commit c95e651
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/parallel/test-net-socket-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ const validDelays = [0, 0.001, 1, 1e6];


for (let i = 0; i < nonNumericDelays.length; i++) {
assert.throws(function() {
assert.throws(() => {
s.setTimeout(nonNumericDelays[i], () => {});
}, TypeError, nonNumericDelays[i]);
}, { code: 'ERR_INVALID_ARG_TYPE' }, nonNumericDelays[i]);
}

for (let i = 0; i < badRangeDelays.length; i++) {
assert.throws(function() {
assert.throws(() => {
s.setTimeout(badRangeDelays[i], () => {});
}, RangeError, badRangeDelays[i]);
}, { code: 'ERR_OUT_OF_RANGE' }, badRangeDelays[i]);
}

for (let i = 0; i < validDelays.length; i++) {
s.setTimeout(validDelays[i], () => {});
}

const server = net.Server();
server.listen(0, common.mustCall(function() {
const socket = net.createConnection(this.address().port);
socket.setTimeout(1, common.mustCall(function() {
server.listen(0, common.mustCall(() => {
const socket = net.createConnection(server.address().port);
socket.setTimeout(1, common.mustCall(() => {
socket.destroy();
server.close();
}));
Expand Down

0 comments on commit c95e651

Please sign in to comment.