File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
sources/solidity/contracts/statements Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ class Registrar {
2323 this . modifierWhitelist = [ ] ;
2424 }
2525
26+ _seekSemiColon ( contract , pos ) {
27+ const end = pos + 5 ;
28+ for ( pos ; pos <= end ; pos ++ ) {
29+ if ( contract [ pos ] === ';' ) break ;
30+ }
31+ return pos ;
32+ }
33+
2634 /**
2735 * Adds injection point to injection points map
2836 * @param {Object } contract instrumentation target
@@ -441,7 +449,7 @@ class Registrar {
441449 ) ;
442450 this . _createInjectionPoint (
443451 contract ,
444- expression . range [ 1 ] + 2 ,
452+ this . _seekSemiColon ( contract . instrumented , expression . range [ 1 ] + 1 ) + 1 ,
445453 {
446454 type : 'injectRequirePost' ,
447455 branchId : contract . branchId ,
Original file line number Diff line number Diff line change 1+ pragma solidity >= 0.8.0 < 0.9.0 ;
2+
3+ contract Test {
4+ function a (uint x ) public {
5+ require (true );
6+ require (true ) ;
7+ require (true ) ;
8+ }
9+ }
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ describe('generic statements', () => {
8585 util . report ( info . solcOutput . errors ) ;
8686 } ) ;
8787
88+ it ( 'should instrument require statements when semi-colon is separated by spaces' , ( ) => {
89+ const info = util . instrumentAndCompile ( 'statements/require' ) ;
90+ util . report ( info . solcOutput . errors ) ;
91+ } ) ;
92+
8893 it ( 'should cover an emitted event statement' , async function ( ) {
8994 const contract = await util . bootstrapCoverage ( 'statements/emit-coverage' , api , this . provider ) ;
9095 coverage . addContract ( contract . instrumented , util . filePath ) ;
You can’t perform that action at this time.
0 commit comments