Skip to content

Commit

Permalink
test: add dgram.Socket.prototype.bind's test
Browse files Browse the repository at this point in the history
Test that an error is thrown when bind() is called on an already bound
socket.

PR-URL: #10894
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Claudio Rodriguez <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Italo A. Casas <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
hiroppy authored and italoacasas committed Jan 30, 2017
1 parent dc826ca commit 90a9917
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/parallel/test-dgram-bind.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');

const socket = dgram.createSocket('udp4');

socket.on('listening', function() {
socket.on('listening', common.mustCall(() => {
assert.throws(() => {
socket.bind();
}, /^Error: Socket is already bound$/);

socket.close();
});
}));

const result = socket.bind(); // should not throw

Expand Down

0 comments on commit 90a9917

Please sign in to comment.