diff options
author | abouthiroppy <git@about-hiroppy.com> | 2017-01-19 15:36:32 +0900 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-01-22 15:36:03 +0100 |
commit | ff75e21662fa5442e9069bfb6f23b625ea1a5b6f (patch) | |
tree | a1d52618cbcd2c24c37c88a035f531009d0ebc49 /test/parallel/test-dgram-bind.js | |
parent | 02ccffb081204c8f9b8b5a2a57354276f5676891 (diff) | |
download | android-node-v8-ff75e21662fa5442e9069bfb6f23b625ea1a5b6f.tar.gz android-node-v8-ff75e21662fa5442e9069bfb6f23b625ea1a5b6f.tar.bz2 android-node-v8-ff75e21662fa5442e9069bfb6f23b625ea1a5b6f.zip |
test: add dgram.Socket.prototype.bind's test
Test that an error is thrown when bind() is called on an already bound
socket.
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/parallel/test-dgram-bind.js')
-rw-r--r-- | test/parallel/test-dgram-bind.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js index 882f2e87bd..f4624358a4 100644 --- a/test/parallel/test-dgram-bind.js +++ b/test/parallel/test-dgram-bind.js @@ -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 |