From 33c9335556185ca0501fa172b779d817f6674837 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 8 Feb 2017 10:15:49 -0500 Subject: [PATCH] test: increase dgram ref()/unref() coverage This commit completes code coverage for dgram's Socket#ref() and Socket#unref() methods. PR-URL: https://github.com/nodejs/node/pull/11240 Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell --- test/parallel/test-dgram-ref.js | 9 ++++++++- test/parallel/test-dgram-unref.js | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-dgram-ref.js b/test/parallel/test-dgram-ref.js index d8981c0b8ad1db..7b79340f924b06 100644 --- a/test/parallel/test-dgram-ref.js +++ b/test/parallel/test-dgram-ref.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())); +} diff --git a/test/parallel/test-dgram-unref.js b/test/parallel/test-dgram-unref.js index 3908335f24485b..6fcdf5d23e1717 100644 --- a/test/parallel/test-dgram-unref.js +++ b/test/parallel/test-dgram-unref.js @@ -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();