@@ -15,6 +15,10 @@ function close() { this.close(); }
1515 // Test listen({port})
1616 net . createServer ( ) . listen ( { port : 0 } )
1717 . on ( 'listening' , common . mustCall ( close ) ) ;
18+ // Test listen(host, port }) on ipv4
19+ net . createServer ( ) . listen ( { host : '127.0.0.1' , port : '3000' } ) . on ( 'listening' , common . mustCall ( close ) ) ;
20+ // Test listen(host, port }) on ipv6
21+ net . createServer ( ) . listen ( { host : '::' , port : '3001' } ) . on ( 'listening' , common . mustCall ( close ) ) ;
1822}
1923
2024// Test listen(port, cb) and listen({ port }, cb) combinations
@@ -66,6 +70,13 @@ const listenOnPort = [
6670 name : 'TypeError' ,
6771 message : / ^ T h e a r g u m e n t ' o p t i o n s ' m u s t h a v e t h e p r o p e r t y " p o r t " o r " p a t h " \. R e c e i v e d .+ $ / ,
6872 } ) ;
73+ } else if ( typeof options . host === 'string' && ! options . host . match ( / ^ [ a - z A - Z 0 - 9 - :% .] + $ / ) ) {
74+ assert . throws ( fn ,
75+ {
76+ code : 'ERR_INVALID_ARG_VALUE' ,
77+ name : 'TypeError' ,
78+ message : / ^ T h e a r g u m e n t ' h o s t ' i s i n v a l i d \. R e c e i v e d .+ $ / ,
79+ } ) ;
6980 } else {
7081 assert . throws ( fn ,
7182 {
@@ -91,4 +102,5 @@ const listenOnPort = [
91102 shouldFailToListen ( { host : 'localhost:3000' } ) ;
92103 shouldFailToListen ( { host : { port : 3000 } } ) ;
93104 shouldFailToListen ( { exclusive : true } ) ;
105+ shouldFailToListen ( { host : '[::]' , port : 3000 } ) ;
94106}
0 commit comments