@@ -11,7 +11,7 @@ var parsers = [JavascriptParser, HiredisParser]
11
11
// Mock the not needed return functions
12
12
function returnReply ( ) { throw new Error ( 'failed' ) }
13
13
function returnError ( ) { throw new Error ( 'failed' ) }
14
- function returnFatalError ( ) { throw new Error ( 'failed' ) }
14
+ function returnFatalError ( err ) { throw err }
15
15
16
16
describe ( 'parsers' , function ( ) {
17
17
describe ( 'general parser functionality' , function ( ) {
@@ -93,6 +93,39 @@ describe('parsers', function () {
93
93
assert . strictEqual ( replyCount , 3 )
94
94
} )
95
95
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
+
96
129
it ( 'chunks getting to big for the bufferPool' , function ( ) {
97
130
// This is a edge case. Chunks should not exceed Math.pow(2, 16) bytes
98
131
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
0 commit comments