Browse Source

test: check that 2nd handle.close() call is a nop

Verify that a second call to handle.close() is a no-op.

PR-URL: https://github.com/nodejs/node/pull/6395
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Ben Noordhuis 9 years ago
committed by Evan Lucas
parent
commit
8a7e68ff83
  1. 1
      test/parallel/test-handle-wrap-isrefed-tty.js
  2. 6
      test/parallel/test-handle-wrap-isrefed.js

1
test/parallel/test-handle-wrap-isrefed-tty.js

@ -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;
}

6
test/parallel/test-handle-wrap-isrefed.js

@ -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);
}
@ -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');
@ -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);
}
@ -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);
}
@ -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);
}
@ -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);
}

Loading…
Cancel
Save