@ -8,13 +8,12 @@ const assert = require('assert');
describe ( 'if, else, and else if statements' , function ( ) {
const fileName = 'test.sol' ;
const filePath = path . resolve ( './test.sol' ) ;
const pathPrefix = './' ;
it ( 'should cover an if statement with a bracketed consequent' , ( done ) => {
const contract = util . getCode ( 'if/if-with-brackets.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -32,7 +31,7 @@ describe('if, else, and else if statements', function(){
// Runs: a(1) => if (x == 1) x = 2;
it ( 'should cover an unbracketed if consequent (single line)' , function ( done ) {
const contract = util . getCode ( 'if/if-no-brackets.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -49,7 +48,7 @@ describe('if, else, and else if statements', function(){
it ( 'should cover an if statement with multiline bracketed consequent' , ( done ) => {
const contract = util . getCode ( 'if/if-with-brackets-multiline.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -67,7 +66,7 @@ describe('if, else, and else if statements', function(){
// Runs: a(1) => if (x == 1)\n x = 3;
it ( 'should cover an unbracketed if consequent (multi-line)' , function ( done ) {
const contract = util . getCode ( 'if/if-no-brackets-multiline.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
// Same results as previous test
@ -83,7 +82,7 @@ describe('if, else, and else if statements', function(){
it ( 'should cover a simple if statement with a failing condition' , ( done ) => {
const contract = util . getCode ( 'if/if-with-brackets.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -101,7 +100,7 @@ describe('if, else, and else if statements', function(){
// Runs: a(2) => if (x == 1){\n throw;\n }else{\n x = 5; \n}
it ( 'should cover an if statement with a bracketed alternate' , ( done ) => {
const contract = util . getCode ( 'if/else-with-brackets.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -117,7 +116,7 @@ describe('if, else, and else if statements', function(){
it ( 'should cover an if statement with an unbracketed alternate' , function ( done ) {
const contract = util . getCode ( 'if/else-without-brackets.sol' ) ;
const info = getInstrumentedVersion ( contract , "test.sol" , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
@ -133,7 +132,7 @@ describe('if, else, and else if statements', function(){
it ( 'should cover nested if statements with missing else statements' , function ( done ) {
const contract = util . getCode ( 'if/nested-if-missing-else.sol' ) ;
const info = getInstrumentedVersion ( contract , fileName , true ) ;
const info = getInstrumentedVersion ( contract , filePath , true ) ;
const coverage = new CoverageMap ( ) ;
coverage . addContract ( info , filePath ) ;
vm . execute ( info . contract , 'a' , [ 2 , 3 , 3 ] ) . then ( events => {
@ -145,4 +144,5 @@ describe('if, else, and else if statements', function(){
done ( ) ;
} ) . catch ( done )
} )
} )