From 0b2dbc4dc1a247aa71d730c1184e77097d59f1d7 Mon Sep 17 00:00:00 2001 From: Alex Rea Date: Thu, 29 Sep 2016 13:10:41 +0100 Subject: [PATCH] Accommodate more if statement possibilities --- instrumentSolidity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentSolidity.js b/instrumentSolidity.js index 1d1208e..12b168d 100644 --- a/instrumentSolidity.js +++ b/instrumentSolidity.js @@ -151,7 +151,7 @@ module.exports = function(pathToFile, instrumentingActive){ var startcol = expression.start - contract.slice(0,expression.start).lastIndexOf('\n') -1; //NB locations for if branches in istanbul are zero length and associated with the start of the if. branchMap[branchId] = {line:linecount, type:'if', locations:[{start:{line:startline, column:startcol},end:{line:startline,column:startcol}},{start:{line:startline, column:startcol},end:{line:startline,column:startcol}}]} - if (contract.slice(expression.consequent.start,1)==='{'){ + if (contract.slice(expression.consequent.start,expression.consequent.end).trim().indexOf('{')===0){ createOrAppendInjectionPoint(expression.consequent.start+1,{type: "callBranchEvent", branchId: branchId, locationIdx: 0} ) }else{ createOrAppendInjectionPoint(expression.consequent.start,{type: "callBranchEvent", branchId: branchId, locationIdx: 0, openBracket:true} ) @@ -368,7 +368,7 @@ module.exports = function(pathToFile, instrumentingActive){ injectionPoint = sortedPoints[x]; //Line instrumentation has to happen first injectionPoints[injectionPoint].sort(function(a,b){ - var eventTypes = ["openParen", "closeBracket","callBranchEvent","callEmptyBranchEvent","callEvent"]; + var eventTypes = ["openParen", "callBranchEvent","callEmptyBranchEvent","callEvent", "closeBracket"]; return eventTypes.indexOf(b.type) - eventTypes.indexOf(a.type); }); for (y in injectionPoints[injectionPoint]){