11'use strict' ;
2- require ( '../common' ) ;
3- var assert = require ( 'assert' ) ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
44
5- var TCP = process . binding ( 'tcp_wrap' ) . TCP ;
6- var WriteWrap = process . binding ( 'stream_wrap' ) . WriteWrap ;
5+ const TCP = process . binding ( 'tcp_wrap' ) . TCP ;
6+ const WriteWrap = process . binding ( 'stream_wrap' ) . WriteWrap ;
77
8- var server = new TCP ( ) ;
8+ const server = new TCP ( ) ;
99
10- var r = server . bind ( '0.0.0.0' , 0 ) ;
11- assert . equal ( 0 , r ) ;
12- var port = { } ;
10+ const r = server . bind ( '0.0.0.0' , 0 ) ;
11+ assert . strictEqual ( 0 , r ) ;
12+ let port = { } ;
1313server . getsockname ( port ) ;
1414port = port . port ;
1515
1616server . listen ( 128 ) ;
1717
18- var sliceCount = 0 , eofCount = 0 ;
18+ let sliceCount = 0 , eofCount = 0 ;
1919
20- var writeCount = 0 ;
21- var recvCount = 0 ;
20+ let writeCount = 0 ;
21+ let recvCount = 0 ;
2222
23- server . onconnection = function ( err , client ) {
24- assert . equal ( 0 , client . writeQueueSize ) ;
23+ server . onconnection = ( err , client ) => {
24+ assert . strictEqual ( 0 , client . writeQueueSize ) ;
2525 console . log ( 'got connection' ) ;
2626
27- function maybeCloseClient ( ) {
28- if ( client . pendingWrites . length == 0 && client . gotEOF ) {
27+ const maybeCloseClient = ( ) => {
28+ if ( client . pendingWrites . length === 0 && client . gotEOF ) {
2929 console . log ( 'close client' ) ;
3030 client . close ( ) ;
3131 }
32- }
32+ } ;
3333
3434 client . readStart ( ) ;
3535 client . pendingWrites = [ ] ;
36- client . onread = function ( err , buffer ) {
36+ client . onread = ( err , buffer ) => {
3737 if ( buffer ) {
3838 assert . ok ( buffer . length > 0 ) ;
3939
40- assert . equal ( 0 , client . writeQueueSize ) ;
40+ assert . strictEqual ( 0 , client . writeQueueSize ) ;
4141
42- var req = new WriteWrap ( ) ;
42+ const req = new WriteWrap ( ) ;
4343 req . async = false ;
4444 const returnCode = client . writeBuffer ( req , buffer ) ;
45- assert . equal ( returnCode , 0 ) ;
45+ assert . strictEqual ( returnCode , 0 ) ;
4646 client . pendingWrites . push ( req ) ;
4747
4848 console . log ( 'client.writeQueueSize: ' + client . writeQueueSize ) ;
4949 // 11 bytes should flush
50- assert . equal ( 0 , client . writeQueueSize ) ;
50+ assert . strictEqual ( 0 , client . writeQueueSize ) ;
5151
5252 if ( req . async )
5353 req . oncomplete = done ;
5454 else
5555 process . nextTick ( done . bind ( null , 0 , client , req ) ) ;
5656
5757 function done ( status , client_ , req_ ) {
58- assert . equal ( req , client . pendingWrites . shift ( ) ) ;
58+ assert . strictEqual ( req , client . pendingWrites . shift ( ) ) ;
5959
6060 // Check parameters.
61- assert . equal ( 0 , status ) ;
62- assert . equal ( client , client_ ) ;
63- assert . equal ( req , req_ ) ;
61+ assert . strictEqual ( 0 , status ) ;
62+ assert . strictEqual ( client , client_ ) ;
63+ assert . strictEqual ( req , req_ ) ;
6464
6565 console . log ( 'client.writeQueueSize: ' + client . writeQueueSize ) ;
66- assert . equal ( 0 , client . writeQueueSize ) ;
66+ assert . strictEqual ( 0 , client . writeQueueSize ) ;
6767
6868 writeCount ++ ;
6969 console . log ( 'write ' + writeCount ) ;
@@ -81,26 +81,25 @@ server.onconnection = function(err, client) {
8181 } ;
8282} ;
8383
84- var net = require ( 'net' ) ;
84+ const net = require ( 'net' ) ;
8585
86- var c = net . createConnection ( port ) ;
87- c . on ( 'connect' , function ( ) {
88- c . end ( 'hello world' ) ;
89- } ) ;
86+ const c = net . createConnection ( port ) ;
87+
88+ c . on ( 'connect' , common . mustCall ( ( ) => { c . end ( 'hello world' ) ; } ) ) ;
9089
9190c . setEncoding ( 'utf8' ) ;
92- c . on ( 'data' , function ( d ) {
93- assert . equal ( 'hello world' , d ) ;
91+ c . on ( 'data' , ( d ) => {
92+ assert . strictEqual ( 'hello world' , d ) ;
9493 recvCount ++ ;
9594} ) ;
9695
97- c . on ( 'close' , function ( ) {
96+ c . on ( 'close' , ( ) => {
9897 console . error ( 'client closed' ) ;
9998} ) ;
10099
101- process . on ( 'exit' , function ( ) {
102- assert . equal ( 1 , sliceCount ) ;
103- assert . equal ( 1 , eofCount ) ;
104- assert . equal ( 1 , writeCount ) ;
105- assert . equal ( 1 , recvCount ) ;
100+ process . on ( 'exit' , ( ) => {
101+ assert . strictEqual ( 1 , sliceCount ) ;
102+ assert . strictEqual ( 1 , eofCount ) ;
103+ assert . strictEqual ( 1 , writeCount ) ;
104+ assert . strictEqual ( 1 , recvCount ) ;
106105} ) ;
0 commit comments