0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-dgram-close-is-not-callback.js
Yosuke Furukawa 207e48c934 dgram: check close callback is function
PR-URL: https://github.com/iojs/io.js/pull/609
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-02-02 18:44:05 +01:00

22 lines
475 B
JavaScript

var assert = require('assert');
var common = require('../common');
var dgram = require('dgram');
var buf = new Buffer(1024);
buf.fill(42);
var socket = dgram.createSocket('udp4');
var closeEvents = 0;
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
// if close callback is not function, ignore the argument.
socket.close('bad argument');
socket.on('close', function() {
++closeEvents;
});
process.on('exit', function() {
assert.equal(closeEvents, 1);
});