Skip to content

Commit

Permalink
test: increase dgram ref()/unref() coverage
Browse files Browse the repository at this point in the history
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 MylesBorins committed Mar 9, 2017
1 parent c7257e7 commit b29165f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 9 additions & 2 deletions test/parallel/test-dgram-ref.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
'use strict';
require('../common');
var dgram = require('dgram');
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()));
}
16 changes: 13 additions & 3 deletions test/parallel/test-dgram-unref.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
const common = require('../common');
var dgram = require('dgram');

var 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.fail, 1000).unref();

0 comments on commit b29165f

Please sign in to comment.