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 <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
Trott authored and targos committed Dec 8, 2018
1 parent 643ca14 commit 6db760c
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 6db760c

Please sign in to comment.