diff options
author | Evan Lucas <evan@btc.com> | 2015-01-08 20:14:44 +0100 |
---|---|---|
committer | Evan Lucas <bertbelder@gmail.com> | 2015-01-08 20:16:39 +0100 |
commit | c9fd9e21622abb7b3893af457f6aaafb2363ab46 (patch) | |
tree | 56c1901f929c83b21ecab237a4be9183ae309db0 /test/parallel | |
parent | b1a208c83cdea0a259cc557314a9566dcad9b5b2 (diff) | |
download | android-node-v8-c9fd9e21622abb7b3893af457f6aaafb2363ab46.tar.gz android-node-v8-c9fd9e21622abb7b3893af457f6aaafb2363ab46.tar.bz2 android-node-v8-c9fd9e21622abb7b3893af457f6aaafb2363ab46.zip |
dgram: make error messages more informative
PR-URL: https://github.com/iojs/io.js/pull/250
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Diffstat (limited to 'test/parallel')
-rw-r--r-- | test/parallel/test-dgram-error-message-address.js | 55 | ||||
-rw-r--r-- | test/parallel/test-dgram-msgsize.js | 3 |
2 files changed, 58 insertions, 0 deletions
diff --git a/test/parallel/test-dgram-error-message-address.js b/test/parallel/test-dgram-error-message-address.js new file mode 100644 index 0000000000..7f80a179c2 --- /dev/null +++ b/test/parallel/test-dgram-error-message-address.js @@ -0,0 +1,55 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var dgram = require('dgram'); + +// IPv4 Test +var socket_ipv4 = dgram.createSocket('udp4'); + +socket_ipv4.on('listening', assert.fail); + +socket_ipv4.on('error', common.mustCall(function(e) { + assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1:' + common.PORT); + assert.equal(e.address, '1.1.1.1'); + assert.equal(e.port, common.PORT); + assert.equal(e.code, 'EADDRNOTAVAIL'); + socket_ipv4.close(); +})); + +socket_ipv4.bind(common.PORT, '1.1.1.1'); + +// IPv6 Test +var socket_ipv6 = dgram.createSocket('udp6'); +var family_ipv6 = 'IPv6'; + +socket_ipv6.on('listening', assert.fail); + +socket_ipv6.on('error', common.mustCall(function(e) { + assert.equal(e.message, 'bind EADDRNOTAVAIL 111::1:' + common.PORT); + assert.equal(e.address, '111::1'); + assert.equal(e.port, common.PORT); + assert.equal(e.code, 'EADDRNOTAVAIL'); + socket_ipv6.close(); +})); + +socket_ipv6.bind(common.PORT, '111::1'); diff --git a/test/parallel/test-dgram-msgsize.js b/test/parallel/test-dgram-msgsize.js index 03f9cb5324..69339ddbac 100644 --- a/test/parallel/test-dgram-msgsize.js +++ b/test/parallel/test-dgram-msgsize.js @@ -31,5 +31,8 @@ sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb)); function cb(err) { assert(err instanceof Error); assert.equal(err.code, 'EMSGSIZE'); + assert.equal(err.address, '127.0.0.1'); + assert.equal(err.port, 12345); + assert.equal(err.message, 'send EMSGSIZE 127.0.0.1:12345'); sock.close(); } |