Skip to content

Commit

Permalink
test: refactor test for net listen on fd0
Browse files Browse the repository at this point in the history
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler

PR-URL: nodejs#10025
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
julianduque authored and Jonathan Darling committed Dec 8, 2016
1 parent 34039a1 commit a1355fd
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions test/parallel/test-net-listen-fd0.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const net = require('net');

var gotError = false;

process.on('exit', function() {
assert(gotError instanceof Error);
});

// this should fail with an async EINVAL error, not throw an exception
net.createServer(common.fail).listen({fd: 0}).on('error', function(e) {
switch (e.code) {
case 'EINVAL':
case 'ENOTSOCK':
gotError = e;
break;
}
});
// This should fail with an async EINVAL error, not throw an exception
net.createServer(common.fail)
.listen({fd: 0})
.on('error', common.mustCall(function(e) {
assert(e instanceof Error);
assert(['EINVAL', 'ENOTSOCK'].includes(e.code));
}));

0 comments on commit a1355fd

Please sign in to comment.