@@ -95,6 +95,11 @@ describe('parsers', function () {
9595 }
9696
9797 describe ( Parser . name , function ( ) {
98+ var replyCount = 0
99+ beforeEach ( function ( ) {
100+ replyCount = 0
101+ } )
102+
98103 it ( 'should not set the bufferOffset to a negative value' , function ( done ) {
99104 if ( Parser . name === 'HiredisReplyParser' ) {
100105 return this . skip ( )
@@ -111,7 +116,6 @@ describe('parsers', function () {
111116 } )
112117
113118 it ( 'multiple parsers do not interfere' , function ( ) {
114- var replyCount = 0
115119 var results = [ 1234567890 , 'foo bar baz' , 'hello world' ]
116120 function checkReply ( reply ) {
117121 assert . strictEqual ( results [ replyCount ] , reply )
@@ -132,7 +136,6 @@ describe('parsers', function () {
132136 } )
133137
134138 it ( 'multiple parsers do not interfere with bulk strings in arrays' , function ( ) {
135- var replyCount = 0
136139 var results = [ [ 'foo' , 'foo bar baz' ] , [ 1234567890 , 'hello world' , 'the end' ] , 'ttttttttttttttttttttttttttttttttttttttttttttttt' ]
137140 function checkReply ( reply ) {
138141 assert . deepEqual ( results [ replyCount ] , reply )
@@ -156,7 +159,6 @@ describe('parsers', function () {
156159 } )
157160
158161 it ( 'returned buffers do not get mutated' , function ( ) {
159- var replyCount = 0
160162 var results = [ new Buffer ( 'aaaaaaaaaa' ) , new Buffer ( 'zzzzzzzzzz' ) ]
161163 function checkReply ( reply ) {
162164 assert . deepEqual ( results [ replyCount ] , reply )
@@ -183,7 +185,6 @@ describe('parsers', function () {
183185 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
184186 'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
185187 var bigString = ( new Array ( Math . pow ( 2 , 17 ) / lorem . length + 1 ) . join ( lorem ) ) // Math.pow(2, 17) chars long
186- var replyCount = 0
187188 var sizes = [ 4 , Math . pow ( 2 , 17 ) ]
188189 function checkReply ( reply ) {
189190 assert . strictEqual ( sizes [ replyCount ] , reply . length )
@@ -201,7 +202,6 @@ describe('parsers', function () {
201202 } )
202203
203204 it ( 'handles multi-bulk reply and check context binding' , function ( ) {
204- var replyCount = 0
205205 function Abc ( ) { }
206206 Abc . prototype . checkReply = function ( reply ) {
207207 assert . strictEqual ( typeof this . log , 'function' )
@@ -226,11 +226,10 @@ describe('parsers', function () {
226226 parser . execute ( new Buffer ( '*1\r\n*1\r\n' ) )
227227 parser . execute ( new Buffer ( '$1\r\na\r\n' ) )
228228
229- assert . equal ( replyCount , 3 , 'check reply should have been called three times' )
229+ assert . strictEqual ( replyCount , 3 , 'check reply should have been called three times' )
230230 } )
231231
232232 it ( 'parser error' , function ( ) {
233- var replyCount = 0
234233 function Abc ( ) { }
235234 Abc . prototype . checkReply = function ( err ) {
236235 assert . strictEqual ( typeof this . log , 'function' )
@@ -249,11 +248,10 @@ describe('parsers', function () {
249248 } )
250249
251250 parser . execute ( new Buffer ( 'a*1\r*1\r$1`zasd\r\na' ) )
252- assert . equal ( replyCount , 1 )
251+ assert . strictEqual ( replyCount , 1 )
253252 } )
254253
255254 it ( 'parser error resets the buffer' , function ( ) {
256- var replyCount = 0
257255 var errCount = 0
258256 function checkReply ( reply ) {
259257 assert . strictEqual ( reply . length , 1 )
@@ -283,7 +281,6 @@ describe('parsers', function () {
283281 } )
284282
285283 it ( 'parser error v3 without returnFatalError specified' , function ( ) {
286- var replyCount = 0
287284 var errCount = 0
288285 function checkReply ( reply ) {
289286 assert . strictEqual ( reply [ 0 ] , 'OK' )
@@ -305,7 +302,6 @@ describe('parsers', function () {
305302
306303 it ( 'should handle \\r and \\n characters properly' , function ( ) {
307304 // If a string contains \r or \n characters it will always be send as a bulk string
308- var replyCount = 0
309305 var entries = [ 'foo\r' , 'foo\r\nbar' , '\r\nСанкт-Пет' , 'foo\r\n' , 'foo' , 'foobar' , 'foo\r' , 'äfooöü' , 'abc' ]
310306 function checkReply ( reply ) {
311307 assert . strictEqual ( reply , entries [ replyCount ] )
@@ -334,25 +330,23 @@ describe('parsers', function () {
334330 } )
335331
336332 it ( 'line breaks in the beginning of the last chunk' , function ( ) {
337- var replyCount = 0
338333 function checkReply ( reply ) {
339334 assert . deepEqual ( reply , [ [ 'a' ] ] , 'Expecting multi-bulk reply of [["a"]]' )
340335 replyCount ++
341336 }
342337 var parser = newParser ( checkReply )
343338
344339 parser . execute ( new Buffer ( '*1\r\n*1\r\n$1\r\na' ) )
345- assert . equal ( replyCount , 0 )
340+ assert . strictEqual ( replyCount , 0 )
346341
347342 parser . execute ( new Buffer ( '\r\n*1\r\n*1\r' ) )
348- assert . equal ( replyCount , 1 )
343+ assert . strictEqual ( replyCount , 1 )
349344 parser . execute ( new Buffer ( '\n$1\r\na\r\n*1\r\n*1\r\n$1\r\na\r\n' ) )
350345
351- assert . equal ( replyCount , 3 , 'check reply should have been called three times' )
346+ assert . strictEqual ( replyCount , 3 , 'check reply should have been called three times' )
352347 } )
353348
354349 it ( 'multiple chunks in a bulk string' , function ( ) {
355- var replyCount = 0
356350 function checkReply ( reply ) {
357351 assert . strictEqual ( reply , 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' )
358352 replyCount ++
@@ -382,11 +376,10 @@ describe('parsers', function () {
382376 assert . strictEqual ( replyCount , 3 )
383377 parser . execute ( new Buffer ( '\n' ) )
384378
385- assert . equal ( replyCount , 4 , 'check reply should have been called three times' )
379+ assert . strictEqual ( replyCount , 4 , 'check reply should have been called three times' )
386380 } )
387381
388382 it ( 'multiple chunks with arrays different types' , function ( ) {
389- var replyCount = 0
390383 var predefinedData = [
391384 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' ,
392385 'test' ,
@@ -432,9 +425,8 @@ describe('parsers', function () {
432425 } )
433426
434427 it ( 'return normal errors' , function ( ) {
435- var replyCount = 0
436428 function checkReply ( reply ) {
437- assert . equal ( reply . message , 'Error message' )
429+ assert . strictEqual ( reply . message , 'Error message' )
438430 replyCount ++
439431 }
440432 var parser = newParser ( {
@@ -449,9 +441,8 @@ describe('parsers', function () {
449441 } )
450442
451443 it ( 'return null for empty arrays and empty bulk strings' , function ( ) {
452- var replyCount = 0
453444 function checkReply ( reply ) {
454- assert . equal ( reply , null )
445+ assert . strictEqual ( reply , null )
455446 replyCount ++
456447 }
457448 var parser = newParser ( checkReply )
@@ -465,9 +456,8 @@ describe('parsers', function () {
465456 } )
466457
467458 it ( 'return value even if all chunks are only 1 character long' , function ( ) {
468- var replyCount = 0
469459 function checkReply ( reply ) {
470- assert . equal ( reply , 1 )
460+ assert . strictEqual ( reply , 1 )
471461 replyCount ++
472462 }
473463 var parser = newParser ( checkReply )
@@ -483,9 +473,8 @@ describe('parsers', function () {
483473 } )
484474
485475 it ( 'do not return before \\r\\n' , function ( ) {
486- var replyCount = 0
487476 function checkReply ( reply ) {
488- assert . equal ( reply , 1 )
477+ assert . strictEqual ( reply , 1 )
489478 replyCount ++
490479 }
491480 var parser = newParser ( checkReply )
@@ -501,7 +490,6 @@ describe('parsers', function () {
501490 } )
502491
503492 it ( 'return data as buffer if requested' , function ( ) {
504- var replyCount = 0
505493 function checkReply ( reply ) {
506494 if ( Array . isArray ( reply ) ) {
507495 reply = reply [ 0 ]
@@ -521,7 +509,6 @@ describe('parsers', function () {
521509 } )
522510
523511 it ( 'handle special case buffer sizes properly' , function ( ) {
524- var replyCount = 0
525512 var entries = [ 'test test ' , 'test test test test ' , 1234 ]
526513 function checkReply ( reply ) {
527514 assert . strictEqual ( reply , entries [ replyCount ] )
@@ -540,7 +527,6 @@ describe('parsers', function () {
540527 if ( Parser . name === 'HiredisReplyParser' ) {
541528 return this . skip ( )
542529 }
543- var replyCount = 0
544530 var entries = [ '123' , '590295810358705700002' , '-99999999999999999' , '4294967290' , '90071992547409920' , '10000040000000000000000000000000000000020' ]
545531 function checkReply ( reply ) {
546532 assert . strictEqual ( typeof reply , 'string' )
@@ -556,7 +542,6 @@ describe('parsers', function () {
556542 } )
557543
558544 it ( 'handle big numbers' , function ( ) {
559- var replyCount = 0
560545 var number = 9007199254740991 // Number.MAX_SAFE_INTEGER
561546 function checkReply ( reply ) {
562547 assert . strictEqual ( reply , number ++ )
@@ -571,7 +556,6 @@ describe('parsers', function () {
571556
572557 it ( 'handle big data with buffers' , function ( done ) {
573558 var chunks
574- var replyCount = 0
575559 var replies = [ ]
576560 var jsParser = Parser . name === 'JavascriptRedisParser'
577561 function checkReply ( reply ) {
@@ -603,7 +587,6 @@ describe('parsers', function () {
603587 } )
604588
605589 it ( 'handle big data' , function ( ) {
606- var replyCount = 0
607590 function checkReply ( reply ) {
608591 assert . strictEqual ( reply . length , 4 * 1024 * 1024 )
609592 replyCount ++
@@ -617,7 +600,6 @@ describe('parsers', function () {
617600
618601 it ( 'handle big data 2 with buffers' , function ( done ) {
619602 this . timeout ( 7500 )
620- var replyCount = 0
621603 var size = 120 * 1024 * 1024
622604 var replyLen = [ size , size * 2 , 11 , 11 ]
623605 function checkReply ( reply ) {
0 commit comments