@ -21,6 +21,7 @@
'use strict' ;
'use strict' ;
const common = require ( '../common' ) ;
const common = require ( '../common' ) ;
const assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
const http = require ( 'http' ) ;
const http = require ( 'http' ) ;
const net = require ( 'net' ) ;
const net = require ( 'net' ) ;
@ -30,16 +31,13 @@ const tests = [];
function test ( fn ) {
function test ( fn ) {
if ( ! tests . length )
if ( ! tests . length )
process . nextTick ( run ) ;
process . nextTick ( run ) ;
tests . push ( fn ) ;
tests . push ( common . mustCall ( fn ) ) ;
}
}
function run ( ) {
function run ( ) {
const fn = tests . shift ( ) ;
const fn = tests . shift ( ) ;
if ( fn ) {
if ( fn ) {
console . log ( '# %s' , fn . name ) ;
fn ( run ) ;
fn ( run ) ;
} else {
console . log ( 'ok' ) ;
}
}
}
}
@ -48,7 +46,7 @@ test(function serverTimeout(cb) {
// just do nothing, we should get a timeout event.
// just do nothing, we should get a timeout event.
} ) ;
} ) ;
server . listen ( common . mustCall ( function ( ) {
server . listen ( common . mustCall ( function ( ) {
http . get ( { port : server . address ( ) . port } ) . on ( 'error' , common . noop ) ;
http . get ( { port : server . address ( ) . port } ) . on ( 'error' , common . mustCall ( ) ) ;
} ) ) ;
} ) ) ;
const s = server . setTimeout ( 50 , common . mustCall ( function ( socket ) {
const s = server . setTimeout ( 50 , common . mustCall ( function ( socket ) {
socket . destroy ( ) ;
socket . destroy ( ) ;
@ -71,7 +69,7 @@ test(function serverRequestTimeout(cb) {
server . listen ( common . mustCall ( function ( ) {
server . listen ( common . mustCall ( function ( ) {
const port = server . address ( ) . port ;
const port = server . address ( ) . port ;
const req = http . request ( { port : port , method : 'POST' } ) ;
const req = http . request ( { port : port , method : 'POST' } ) ;
req . on ( 'error' , common . noop ) ;
req . on ( 'error' , common . mustCall ( ) ) ;
req . write ( 'Hello' ) ;
req . write ( 'Hello' ) ;
// req is in progress
// req is in progress
} ) ) ;
} ) ) ;
@ -89,7 +87,7 @@ test(function serverResponseTimeout(cb) {
} ) ;
} ) ;
server . listen ( common . mustCall ( function ( ) {
server . listen ( common . mustCall ( function ( ) {
const port = server . address ( ) . port ;
const port = server . address ( ) . port ;
http . get ( { port : port } ) . on ( 'error' , common . noop ) ;
http . get ( { port : port } ) . on ( 'error' , common . mustCall ( ) ) ;
} ) ) ;
} ) ) ;
} ) ;
} ) ;
@ -107,7 +105,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
} ) ;
} ) ;
server . listen ( common . mustCall ( function ( ) {
server . listen ( common . mustCall ( function ( ) {
const port = server . address ( ) . port ;
const port = server . address ( ) . port ;
http . get ( { port : port } ) . on ( 'error' , common . noop ) ;
http . get ( { port : port } ) . on ( 'error' , common . mustCall ( ) ) ;
} ) ) ;
} ) ) ;
} ) ;
} ) ;