From 5566d6da2e5ef9b518d865420df97dfa60b3c6c6 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Mon, 20 Apr 2020 15:36:23 -0700 Subject: [PATCH] Add logicalOR coverage for "return" conditions --- lib/instrumenter.js | 2 ++ lib/parse.js | 3 +++ test/units/or.js | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/instrumenter.js b/lib/instrumenter.js index 5aab842..338b685 100644 --- a/lib/instrumenter.js +++ b/lib/instrumenter.js @@ -61,6 +61,8 @@ class Instrumenter { // First, we run over the original contract to get the source mapping. let ast = SolidityParser.parse(contract.source, {range: true}); + //console.log(JSON.stringify(ast, null, ' ')) + parse[ast.type](contract, ast); const retValue = JSON.parse(JSON.stringify(contract)); // Possibly apotropaic. diff --git a/lib/parse.js b/lib/parse.js index abffb9a..2e45cde 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -185,6 +185,9 @@ parse.SourceUnit = function(contract, expression) { parse.ReturnStatement = function(contract, expression) { register.statement(contract, expression); + + parse[expression.expression.type] && + parse[expression.expression.type](contract, expression.expression, true); }; // TODO:Investigate node structure diff --git a/test/units/or.js b/test/units/or.js index 0d7ecef..4b59246 100644 --- a/test/units/or.js +++ b/test/units/or.js @@ -159,7 +159,7 @@ describe('logical OR branches', () => { 5: 1, }); assert.deepEqual(mapping[util.filePath].b, { - + 1: [ 1, 0 ] }); assert.deepEqual(mapping[util.filePath].s, { 1: 1, @@ -182,7 +182,7 @@ describe('logical OR branches', () => { 5: 2, }); assert.deepEqual(mapping[util.filePath].b, { - + 1: [ 1, 1 ] }); assert.deepEqual(mapping[util.filePath].s, { 1: 2,