Add logicalOR coverage for "while" conditions

logical-or-coverage
cgewecke 5 years ago
parent b85e10288f
commit d7a88c9933
  1. 11
      lib/parse.js
  2. 4
      test/units/or.js

@ -39,6 +39,13 @@ parse.BinaryOperation = function(contract, expression, skipStatementRegistry) {
} }
} }
parse.TupleExpression = function(contract, expression, skipStatementRegistry) {
expression.components.forEach(component => {
parse[component.type] &&
parse[component.type](contract, component, skipStatementRegistry);
});
}
parse.FunctionCall = function(contract, expression, skipStatementRegistry) { parse.FunctionCall = function(contract, expression, skipStatementRegistry) {
// In any given chain of call expressions, only the last one will fail this check. // In any given chain of call expressions, only the last one will fail this check.
// This makes sure we don't instrument a chain of expressions multiple times. // This makes sure we don't instrument a chain of expressions multiple times.
@ -197,6 +204,10 @@ parse.VariableDeclarationStatement = function (contract, expression) {
parse.WhileStatement = function (contract, expression) { parse.WhileStatement = function (contract, expression) {
register.statement(contract, expression); register.statement(contract, expression);
parse[expression.condition.type] &&
parse[expression.condition.type](contract, expression.condition, true);
parse[expression.body.type] && parse[expression.body.type] &&
parse[expression.body.type](contract, expression.body); parse[expression.body.type](contract, expression.body);
}; };

@ -114,7 +114,7 @@ describe('logical OR branches', () => {
5: 1, 6: 1, 7: 2 5: 1, 6: 1, 7: 2
}); });
assert.deepEqual(mapping[util.filePath].b, { assert.deepEqual(mapping[util.filePath].b, {
1: [3, 0]
}); });
assert.deepEqual(mapping[util.filePath].s, { assert.deepEqual(mapping[util.filePath].s, {
1: 1, 2: 1 1: 1, 2: 1
@ -137,7 +137,7 @@ describe('logical OR branches', () => {
5: 2, 6: 2, 7: 4 5: 2, 6: 2, 7: 4
}); });
assert.deepEqual(mapping[util.filePath].b, { assert.deepEqual(mapping[util.filePath].b, {
1: [3, 3]
}); });
assert.deepEqual(mapping[util.filePath].s, { assert.deepEqual(mapping[util.filePath].s, {
1: 2, 2: 2 1: 2, 2: 2

Loading…
Cancel
Save