Tolerate whitespace between `require` and terminating `;` (#884)

pull/887/head
cgewecke 8 months ago committed by GitHub
parent 09a7c833ae
commit 4f5626d654
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      lib/registrar.js
  2. 9
      test/sources/solidity/contracts/statements/require.sol
  3. 5
      test/units/statements.js

@ -23,6 +23,14 @@ class Registrar {
this.modifierWhitelist = []; this.modifierWhitelist = [];
} }
_seekSemiColon(contract, pos) {
const end = pos + 5;
for(pos; pos <= end; pos++) {
if (contract[pos] === ';') break;
}
return pos;
}
/** /**
* Adds injection point to injection points map * Adds injection point to injection points map
* @param {Object} contract instrumentation target * @param {Object} contract instrumentation target
@ -441,7 +449,7 @@ class Registrar {
); );
this._createInjectionPoint( this._createInjectionPoint(
contract, contract,
expression.range[1] + 2, this._seekSemiColon(contract.instrumented, expression.range[1] + 1) + 1,
{ {
type: 'injectRequirePost', type: 'injectRequirePost',
branchId: contract.branchId, branchId: contract.branchId,

@ -0,0 +1,9 @@
pragma solidity >=0.8.0 <0.9.0;
contract Test {
function a(uint x) public {
require(true);
require(true) ;
require(true) ;
}
}

@ -85,6 +85,11 @@ describe('generic statements', () => {
util.report(info.solcOutput.errors); util.report(info.solcOutput.errors);
}); });
it('should instrument require statements when semi-colon is separated by spaces', () => {
const info = util.instrumentAndCompile('statements/require');
util.report(info.solcOutput.errors);
});
it('should cover an emitted event statement', async function() { it('should cover an emitted event statement', async function() {
const contract = await util.bootstrapCoverage('statements/emit-coverage', api, this.provider); const contract = await util.bootstrapCoverage('statements/emit-coverage', api, this.provider);
coverage.addContract(contract.instrumented, util.filePath); coverage.addContract(contract.instrumented, util.filePath);

Loading…
Cancel
Save