|
|
|
@ -6,27 +6,27 @@ injector.callEvent = function injectCallEvent(contract, fileName, injectionPoint |
|
|
|
|
const linecount = (contract.instrumented.slice(0, injectionPoint).match(/\n/g) || []).length + 1; |
|
|
|
|
contract.runnableLines.push(linecount); |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
'__Coverage'+contract.contractName+'(\'' + fileName + '\',' + linecount + ');\n' + |
|
|
|
|
'__Coverage' + contract.contractName + '(\'' + fileName + '\',' + linecount + ');\n' + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
injector.callFunctionEvent = function injectCallFunctionEvent(contract, fileName, injectionPoint, injection) { |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
'__FunctionCoverage'+contract.contractName+'(\'' + fileName + '\',' + injection.fnId + ');\n' + |
|
|
|
|
'__FunctionCoverage' + contract.contractName + '(\'' + fileName + '\',' + injection.fnId + ');\n' + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
injector.callBranchEvent = function injectCallFunctionEvent(contract, fileName, injectionPoint, injection) { |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
(injection.openBracket ? '{' : '') + |
|
|
|
|
'__BranchCoverage'+contract.contractName+'(\'' + fileName + '\',' + injection.branchId + ',' + injection.locationIdx + ')' + |
|
|
|
|
'__BranchCoverage' + contract.contractName + '(\'' + fileName + '\',' + injection.branchId + ',' + injection.locationIdx + ')' + |
|
|
|
|
(injection.comma ? ',' : ';') + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
injector.callEmptyBranchEvent = function injectCallEmptyBranchEvent(contract, fileName, injectionPoint, injection) { |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
'else { __BranchCoverage'+contract.contractName+'(\'' + fileName + '\',' + injection.branchId + ',' + injection.locationIdx + ');}\n' + |
|
|
|
|
'else { __BranchCoverage' + contract.contractName + '(\'' + fileName + '\',' + injection.branchId + ',' + injection.locationIdx + ');}\n' + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -44,16 +44,16 @@ injector.literal = function injectLiteral(contract, fileName, injectionPoint, in |
|
|
|
|
|
|
|
|
|
injector.statement = function injectStatement(contract, fileName, injectionPoint, injection) { |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
' __StatementCoverage'+contract.contractName+'(\'' + fileName + '\',' + injection.statementId + ');\n' + |
|
|
|
|
' __StatementCoverage' + contract.contractName + '(\'' + fileName + '\',' + injection.statementId + ');\n' + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
injector.eventDefinition = function injectEventDefinition(contract, fileName, injectionPoint, injection) { |
|
|
|
|
contract.instrumented = contract.instrumented.slice(0, injectionPoint) + |
|
|
|
|
'event __Coverage'+contract.contractName+'(string fileName, uint256 lineNumber);\n' + |
|
|
|
|
'event __FunctionCoverage'+contract.contractName+'(string fileName, uint256 fnId);\n' + |
|
|
|
|
'event __StatementCoverage'+contract.contractName+'(string fileName, uint256 statementId);\n' + |
|
|
|
|
'event __BranchCoverage'+contract.contractName+'(string fileName, uint256 branchId, uint256 locationIdx);\n' + |
|
|
|
|
'event __Coverage' + contract.contractName + '(string fileName, uint256 lineNumber);\n' + |
|
|
|
|
'event __FunctionCoverage' + contract.contractName + '(string fileName, uint256 fnId);\n' + |
|
|
|
|
'event __StatementCoverage' + contract.contractName + '(string fileName, uint256 statementId);\n' + |
|
|
|
|
'event __BranchCoverage' + contract.contractName + '(string fileName, uint256 branchId, uint256 locationIdx);\n' + |
|
|
|
|
contract.instrumented.slice(injectionPoint); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|