You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
813 B
39 lines
813 B
13 years ago
|
var Parser = require('../lib/parser/hiredis').Parser;
|
||
|
var assert = require('assert');
|
||
|
|
||
|
/*
|
||
|
This test makes sure that exceptions thrown inside of "reply" event handlers
|
||
|
are not trapped and mistakenly emitted as parse errors.
|
||
|
*/
|
||
|
(function testExecuteDoesNotCatchReplyCallbackExceptions() {
|
||
|
var parser = new Parser();
|
||
|
var replies = [{}];
|
||
|
|
||
|
parser.reader = {
|
||
|
feed: function() {},
|
||
|
get: function() {
|
||
|
return replies.shift();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var emittedError = false;
|
||
|
var caughtException = false;
|
||
|
|
||
|
parser
|
||
|
.on('error', function() {
|
||
|
emittedError = true;
|
||
|
})
|
||
|
.on('reply', function() {
|
||
|
throw new Error('bad');
|
||
|
});
|
||
|
|
||
|
try {
|
||
|
parser.execute();
|
||
|
} catch (err) {
|
||
|
caughtException = true;
|
||
|
}
|
||
|
|
||
|
assert.equal(caughtException, true);
|
||
|
assert.equal(emittedError, false);
|
||
|
})();
|