@@ -64,6 +64,35 @@ describe('parsers', function () {
64
64
65
65
parsers . forEach ( function ( Parser ) {
66
66
describe ( Parser . name , function ( ) {
67
+ it ( 'multiple parsers do not interfere' , function ( ) {
68
+ var replyCount = 0
69
+ var results = [ 1234567890 , 'foo bar baz' , 'hello world' ]
70
+ function checkReply ( reply ) {
71
+ assert . strictEqual ( results [ replyCount ] , reply )
72
+ replyCount ++
73
+ }
74
+ var parserOne = new Parser ( {
75
+ returnReply : checkReply ,
76
+ returnError : returnError ,
77
+ returnFatalError : returnFatalError
78
+ } )
79
+ var parserTwo = new Parser ( {
80
+ returnReply : checkReply ,
81
+ returnError : returnError ,
82
+ returnFatalError : returnFatalError
83
+ } )
84
+ parserOne . execute ( new Buffer ( '+foo ' ) )
85
+ parserOne . execute ( new Buffer ( 'bar ' ) )
86
+ assert . strictEqual ( replyCount , 0 )
87
+ parserTwo . execute ( new Buffer ( ':1234567890\r\n+hello ' ) )
88
+ assert . strictEqual ( replyCount , 1 )
89
+ parserTwo . execute ( new Buffer ( 'wor' ) )
90
+ parserOne . execute ( new Buffer ( 'baz\r\n' ) )
91
+ assert . strictEqual ( replyCount , 2 )
92
+ parserTwo . execute ( new Buffer ( 'ld\r\n' ) )
93
+ assert . strictEqual ( replyCount , 3 )
94
+ } )
95
+
67
96
it ( 'chunks getting to big for the bufferPool' , function ( ) {
68
97
// This is a edge case. Chunks should not exceed Math.pow(2, 16) bytes
69
98
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
0 commit comments