Debian Codegraph @

test/instrumentation/test-try.js

raw
1 /*jslint nomen: true */
2 var helper = require('../helper'),
3 code,
4 verifier;
5
6 /*jshint maxlen: 500 */
7 module.exports = {
8 "with an simple try catch": {
9 setUp: function (cb) {
10 code = [
11 'try {',
12 ' if (args[0] === "X") { throw "foo"; }',
13 ' output = args[0];',
14 '} catch (ex) {',
15 ' output="Y";',
16 '} finally {',
17 ' output += 1;',
18 '}'
19 ];
20 verifier = helper.verifier(__filename, code);
21 cb();
22 },
23
24 "should cover happy path correctly": function (test) {
25 verifier.verify(test, [1], 2, { lines: { '1': 1, '2': 1, 3: 1, 5: 0, 7: 1 }, branches: { 1: [ 0, 1 ] }, functions: {}, statements: { '1': 1, '2': 1, '3': 0, 4: 1, 5: 0, 6: 1} });
26 test.done();
27 },
28 "should cover sad path correctly": function (test) {
29 verifier.verify(test, ['X'], 'Y1', { lines: { '1': 1, '2': 1, 3: 0, 5: 1, 7: 1 }, branches: { 1: [ 1, 0 ] }, functions: {}, statements: { '1': 1, '2': 1, '3': 1, 4: 0, 5: 1, 6: 1} });
30 test.done();
31 }
32 }
33 };
34