File tree 3 files changed +23
-1
lines changed
sources/solidity/contracts/statements
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ class Registrar {
23
23
this . modifierWhitelist = [ ] ;
24
24
}
25
25
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
+
26
34
/**
27
35
* Adds injection point to injection points map
28
36
* @param {Object } contract instrumentation target
@@ -441,7 +449,7 @@ class Registrar {
441
449
) ;
442
450
this . _createInjectionPoint (
443
451
contract ,
444
- expression . range [ 1 ] + 2 ,
452
+ this . _seekSemiColon ( contract . instrumented , expression . range [ 1 ] + 1 ) + 1 ,
445
453
{
446
454
type : 'injectRequirePost' ,
447
455
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', () => {
85
85
util . report ( info . solcOutput . errors ) ;
86
86
} ) ;
87
87
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
+
88
93
it ( 'should cover an emitted event statement' , async function ( ) {
89
94
const contract = await util . bootstrapCoverage ( 'statements/emit-coverage' , api , this . provider ) ;
90
95
coverage . addContract ( contract . instrumented , util . filePath ) ;
You can’t perform that action at this time.
0 commit comments