Permalink
Browse files

test: increase dgram ref()/unref() coverage

This commit completes code coverage for dgram's Socket#ref() and
Socket#unref() methods.

PR-URL: #11240
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
cjihrig authored and italoacasas committed Feb 8, 2017
1 parent d9ed965 commit 2333cd315546d66d797581d211dde685658377fa
Showing with 21 additions and 4 deletions.
  1. +8 −1 test/parallel/test-dgram-ref.js
  2. +13 −3 test/parallel/test-dgram-unref.js
@@ -1,7 +1,14 @@
'use strict';
-require('../common');
+const common = require('../common');
const dgram = require('dgram');
// should not hang, see #1282
dgram.createSocket('udp4');
dgram.createSocket('udp6');
+
+{
+ // Test the case of ref()'ing a socket with no handle.
+ const s = dgram.createSocket('udp4');
+
+ s.close(common.mustCall(() => s.ref()));
+}
@@ -2,8 +2,18 @@
const common = require('../common');
const dgram = require('dgram');
-const s = dgram.createSocket('udp4');
-s.bind();
-s.unref();
+{
+ // Test the case of unref()'ing a socket with a handle.
+ const s = dgram.createSocket('udp4');
+ s.bind();
+ s.unref();
+}
+
+{
+ // Test the case of unref()'ing a socket with no handle.
+ const s = dgram.createSocket('udp4');
+
+ s.close(common.mustCall(() => s.unref()));
+}
setTimeout(common.mustNotCall(), 1000).unref();

0 comments on commit 2333cd3

Please sign in to comment.