Skip to content

Commit

Permalink
test: check that 2nd handle.close() call is a nop
Browse files Browse the repository at this point in the history
Verify that a second call to handle.close() is a no-op.

PR-URL: #6395
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
bnoordhuis committed Apr 27, 2016
1 parent a58d483 commit 4282405
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/parallel/test-handle-wrap-isrefed-tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (process.argv[2] === 'child') {
tty.unref();
assert(tty._handle.unrefed(), true);
tty._handle.close(common.mustCall(() => assert(tty._handle.unrefed(), true)));
tty._handle.close(common.fail);
assert(tty._handle.unrefed(), true);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-handle-wrap-isrefed.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function makeAssert(message) {
cp.ref();
assert(cp._handle.unrefed(), false);
cp._handle.close(common.mustCall(() => assert(cp._handle.unrefed(), true)));
cp._handle.close(common.fail);
assert(cp._handle.unrefed(), false);
}

Expand All @@ -41,6 +42,7 @@ function makeAssert(message) {
assert(sock4._handle.unrefed(), false);
sock4._handle.close(
common.mustCall(() => assert(sock4._handle.unrefed(), true)));
sock4._handle.close(common.fail);
assert(sock4._handle.unrefed(), false);

const sock6 = dgram.createSocket('udp6');
Expand All @@ -52,6 +54,7 @@ function makeAssert(message) {
assert(sock6._handle.unrefed(), false);
sock6._handle.close(
common.mustCall(() => assert(sock6._handle.unrefed(), true)));
sock6._handle.close(common.fail);
assert(sock6._handle.unrefed(), false);
}

Expand All @@ -68,6 +71,7 @@ function makeAssert(message) {
handle.ref();
assert(handle.unrefed(), false);
handle.close(common.mustCall(() => assert(handle.unrefed(), true)));
handle.close(common.fail);
assert(handle.unrefed(), false);
}

Expand All @@ -88,6 +92,7 @@ function makeAssert(message) {
assert(server._unref, false);
server._handle.close(
common.mustCall(() => assert(server._handle.unrefed(), true)));
server._handle.close(common.fail);
assert(server._handle.unrefed(), false);
}

Expand All @@ -103,5 +108,6 @@ function makeAssert(message) {
assert(timer._handle.unrefed(), false);
timer._handle.close(
common.mustCall(() => assert(timer._handle.unrefed(), true)));
timer._handle.close(common.fail);
assert(timer._handle.unrefed(), false);
}

0 comments on commit 4282405

Please sign in to comment.