-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor test for net listen on fd0
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler
- Loading branch information
1 parent
8264a22
commit 7255098
Showing
1 changed file
with
10 additions
and
18 deletions.
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
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)); | ||
})); |