From 655fb79530f2e57c316b537850d39b64b785d7a6 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Wed, 17 Jun 2020 09:01:43 -0700 Subject: [PATCH] Parse TryStatements and catchClauses (#522) --- lib/parse.js | 11 +++++++++++ .../projects/solc-6/contracts/ContractA.sol | 2 +- test/units/buidler/standard.js | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index 29706d7..38aeb35 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -171,6 +171,17 @@ parse.ReturnStatement = function(contract, expression) { parse[subExpression.argument.type](contract, expression.argument); };*/ +parse.TryStatement = function(contract, expression) { + register.statement(contract, expression); + parse[expression.body.type] && + parse[expression.body.type](contract, expression.body); + + for (let x = 0; x < expression.catchClauses.length; x++) { + parse[expression.catchClauses[x].body.type] && + parse[expression.catchClauses[x].body.type](contract, expression.catchClauses[x].body); + } +}; + parse.UsingStatement = function (contract, expression) { parse[expression.for.type] && parse[expression.for.type](contract, expression.for); diff --git a/test/integration/projects/solc-6/contracts/ContractA.sol b/test/integration/projects/solc-6/contracts/ContractA.sol index 06b987f..75bb919 100644 --- a/test/integration/projects/solc-6/contracts/ContractA.sol +++ b/test/integration/projects/solc-6/contracts/ContractA.sol @@ -43,7 +43,7 @@ contract ContractA is ContractB { errorCount++; return (0, false); } catch (bytes memory) { - errorCount++; + errorCount = errorCount + 1; return (0, false); } } diff --git a/test/units/buidler/standard.js b/test/units/buidler/standard.js index be127d6..342b6c8 100644 --- a/test/units/buidler/standard.js +++ b/test/units/buidler/standard.js @@ -284,7 +284,7 @@ describe('Buidler Plugin: standard use cases', function() { const expected = [ { file: mock.pathToContract(buidlerConfig, 'ContractA.sol'), - pct: 87.5 + pct: 61.54 }, { file: mock.pathToContract(buidlerConfig, 'ContractB.sol'),