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 <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
hiroppy authored and jasnell committed Mar 8, 2017
1 parent eb74100 commit 535a424
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 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');
var assert = require('assert');
var dgram = require('dgram');
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');

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

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

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

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

Expand Down

0 comments on commit 535a424

Please sign in to comment.