@@ -11,7 +11,7 @@ var parsers = [JavascriptParser, HiredisParser]
1111// Mock the not needed return functions
1212function returnReply ( ) { throw new Error ( 'failed' ) }
1313function returnError ( ) { throw new Error ( 'failed' ) }
14- function returnFatalError ( ) { throw new Error ( 'failed' ) }
14+ function returnFatalError ( err ) { throw err }
1515
1616describe ( 'parsers' , function ( ) {
1717 describe ( 'general parser functionality' , function ( ) {
@@ -93,6 +93,39 @@ describe('parsers', function () {
9393 assert . strictEqual ( replyCount , 3 )
9494 } )
9595
96+ it ( 'multiple parsers do not interfere with bulk strings in arrays' , function ( ) {
97+ var replyCount = 0
98+ var results = [ [ 'foo' , 'foo bar baz' ] , [ 1234567890 , 'hello world' , 'the end' ] , 'ttttttttttttttttttttttttttttttttttttttttttttttt' ]
99+ function checkReply ( reply ) {
100+ console . log ( reply )
101+ assert . deepEqual ( results [ replyCount ] , reply )
102+ replyCount ++
103+ }
104+ var parserOne = new Parser ( {
105+ returnReply : checkReply ,
106+ returnError : returnError ,
107+ returnFatalError : returnFatalError
108+ } )
109+ var parserTwo = new Parser ( {
110+ returnReply : checkReply ,
111+ returnError : returnError ,
112+ returnFatalError : returnFatalError
113+ } )
114+ parserOne . execute ( new Buffer ( '*2\r\n+foo\r\n$11\r\nfoo ' ) )
115+ parserOne . execute ( new Buffer ( 'bar ' ) )
116+ assert . strictEqual ( replyCount , 0 )
117+ parserTwo . execute ( new Buffer ( '*3\r\n:1234567890\r\n$11\r\nhello ' ) )
118+ assert . strictEqual ( replyCount , 0 )
119+ parserOne . execute ( new Buffer ( 'baz\r\n+ttttttttttttttttttttttttt' ) )
120+ assert . strictEqual ( replyCount , 1 )
121+ parserTwo . execute ( new Buffer ( 'wor' ) )
122+ parserTwo . execute ( new Buffer ( 'ld\r\n' ) )
123+ assert . strictEqual ( replyCount , 1 )
124+ parserTwo . execute ( new Buffer ( '+the end\r\n' ) )
125+ assert . strictEqual ( replyCount , 2 )
126+ parserOne . execute ( new Buffer ( 'tttttttttttttttttttttt\r\n' ) )
127+ } )
128+
96129 it ( 'chunks getting to big for the bufferPool' , function ( ) {
97130 // This is a edge case. Chunks should not exceed Math.pow(2, 16) bytes
98131 var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
0 commit comments