From d7a88c9933a8cc72bc1a5cffaee2d10b94fd3594 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Mon, 20 Apr 2020 15:18:05 -0700 Subject: [PATCH] Add logicalOR coverage for "while" conditions --- lib/parse.js | 11 +++++++++++ test/units/or.js | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index 180392d..abffb9a 100644 --- a/lib/parse.js +++ b/lib/parse.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) { // 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. @@ -197,6 +204,10 @@ parse.VariableDeclarationStatement = function (contract, expression) { parse.WhileStatement = function (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](contract, expression.body); }; diff --git a/test/units/or.js b/test/units/or.js index 3414731..0d7ecef 100644 --- a/test/units/or.js +++ b/test/units/or.js @@ -114,7 +114,7 @@ describe('logical OR branches', () => { 5: 1, 6: 1, 7: 2 }); assert.deepEqual(mapping[util.filePath].b, { - + 1: [3, 0] }); assert.deepEqual(mapping[util.filePath].s, { 1: 1, 2: 1 @@ -137,7 +137,7 @@ describe('logical OR branches', () => { 5: 2, 6: 2, 7: 4 }); assert.deepEqual(mapping[util.filePath].b, { - + 1: [3, 3] }); assert.deepEqual(mapping[util.filePath].s, { 1: 2, 2: 2