-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dgram: check close callback is function
PR-URL: #609 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com>
- Loading branch information
1 parent
6ac8bdc
commit 207e48c
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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); | ||
}); |