Skip to content

Commit b471392

Browse files
committedFeb 10, 2017
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b594b3b commit b471392

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
 

‎test/parallel/test-dgram-ref.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const dgram = require('dgram');
44

55
// should not hang, see #1282
66
dgram.createSocket('udp4');
77
dgram.createSocket('udp6');
8+
9+
{
10+
// Test the case of ref()'ing a socket with no handle.
11+
const s = dgram.createSocket('udp4');
12+
13+
s.close(common.mustCall(() => s.ref()));
14+
}

‎test/parallel/test-dgram-unref.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
const common = require('../common');
33
const dgram = require('dgram');
44

5-
const s = dgram.createSocket('udp4');
6-
s.bind();
7-
s.unref();
5+
{
6+
// Test the case of unref()'ing a socket with a handle.
7+
const s = dgram.createSocket('udp4');
8+
s.bind();
9+
s.unref();
10+
}
11+
12+
{
13+
// Test the case of unref()'ing a socket with no handle.
14+
const s = dgram.createSocket('udp4');
15+
16+
s.close(common.mustCall(() => s.unref()));
17+
}
818

919
setTimeout(common.mustNotCall(), 1000).unref();

0 commit comments

Comments
 (0)
Please sign in to comment.