Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / redis / benches / hiredis_parser.js
1 var Parser = require('../lib/parser/hiredis').Parser;
2 var assert = require('assert');
3
4 /*
5 This test makes sure that exceptions thrown inside of "reply" event handlers
6 are not trapped and mistakenly emitted as parse errors.
7 */
8 (function testExecuteDoesNotCatchReplyCallbackExceptions() {
9   var parser = new Parser();
10   var replies = [{}];
11
12   parser.reader = {
13     feed: function() {},
14     get: function() {
15       return replies.shift();
16     }
17   };
18
19   var emittedError = false;
20   var caughtException = false;
21
22   parser
23     .on('error', function() {
24       emittedError = true;
25     })
26     .on('reply', function() {
27       throw new Error('bad');
28     });
29
30   try {
31     parser.execute();
32   } catch (err) {
33     caughtException = true;
34   }
35
36   assert.equal(caughtException, true);
37   assert.equal(emittedError, false);
38 })();