11const assert = require ( 'assert' ) ;
22const util = require ( './../util/util.js' ) ;
3-
4- const client = require ( 'ganache-cli' ) ;
53const Coverage = require ( './../../lib/coverage' ) ;
64const Api = require ( './../../lib/api' )
75
86describe ( 'ternary conditionals' , ( ) => {
97 let coverage ;
108 let api ;
119
12- before ( async ( ) => {
13- api = new Api ( { silent : true } ) ;
14- await api . ganache ( client ) ;
15- } )
10+ before ( async ( ) => api = new Api ( { silent : true } ) ) ;
1611 beforeEach ( ( ) => coverage = new Coverage ( ) ) ;
1712 after ( async ( ) => await api . finish ( ) ) ;
1813
19- async function setupAndRun ( solidityFile ) {
20- const contract = await util . bootstrapCoverage ( solidityFile , api ) ;
14+ async function setupAndRun ( solidityFile , provider ) {
15+ const contract = await util . bootstrapCoverage ( solidityFile , api , provider ) ;
2116 coverage . addContract ( contract . instrumented , util . filePath ) ;
22- await contract . instance . a ( ) ;
17+ await contract . instance . a ( contract . gas ) ;
2318 return coverage . generate ( contract . data , util . pathPrefix ) ;
2419 }
2520
2621 it ( 'should cover a conditional that reaches the consequent (same-line)' , async function ( ) {
27- const mapping = await setupAndRun ( 'conditional/sameline-consequent' ) ;
22+ const mapping = await setupAndRun ( 'conditional/sameline-consequent' , this . provider ) ;
2823
2924 assert . deepEqual ( mapping [ util . filePath ] . l , {
3025 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -41,7 +36,7 @@ describe('ternary conditionals', () => {
4136 } ) ;
4237
4338 it ( 'should cover an unbracketed conditional that reaches the consequent (same-line)' , async function ( ) {
44- const mapping = await setupAndRun ( 'conditional/unbracketed-condition' ) ;
39+ const mapping = await setupAndRun ( 'conditional/unbracketed-condition' , this . provider ) ;
4540
4641 assert . deepEqual ( mapping [ util . filePath ] . l , {
4742 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -58,7 +53,7 @@ describe('ternary conditionals', () => {
5853 } ) ;
5954
6055 it ( 'should cover a multi-part conditional (&&) that reaches the consequent' , async function ( ) {
61- const mapping = await setupAndRun ( 'conditional/and-condition' ) ;
56+ const mapping = await setupAndRun ( 'conditional/and-condition' , this . provider ) ;
6257
6358 assert . deepEqual ( mapping [ util . filePath ] . l , {
6459 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -75,7 +70,7 @@ describe('ternary conditionals', () => {
7570 } ) ;
7671
7772 it ( 'should cover a multi-part conditional (||) that reaches the consequent' , async function ( ) {
78- const mapping = await setupAndRun ( 'conditional/or-condition' ) ;
73+ const mapping = await setupAndRun ( 'conditional/or-condition' , this . provider ) ;
7974
8075 assert . deepEqual ( mapping [ util . filePath ] . l , {
8176 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -92,7 +87,7 @@ describe('ternary conditionals', () => {
9287 } ) ;
9388
9489 it ( 'should cover a multi-part unbracketed conditional (||) that reaches the consequent' , async function ( ) {
95- const mapping = await setupAndRun ( 'conditional/unbracketed-or-condition' ) ;
90+ const mapping = await setupAndRun ( 'conditional/unbracketed-or-condition' , this . provider ) ;
9691
9792 assert . deepEqual ( mapping [ util . filePath ] . l , {
9893 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -109,7 +104,7 @@ describe('ternary conditionals', () => {
109104 } ) ;
110105
111106 it ( 'should cover an always-false multi-part unbracketed conditional (||)' , async function ( ) {
112- const mapping = await setupAndRun ( 'conditional/or-always-false-condition' ) ;
107+ const mapping = await setupAndRun ( 'conditional/or-always-false-condition' , this . provider ) ;
113108
114109 assert . deepEqual ( mapping [ util . filePath ] . l , {
115110 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -126,7 +121,7 @@ describe('ternary conditionals', () => {
126121 } ) ;
127122
128123 it ( 'should cover a conditional that reaches the alternate (same-line)' , async function ( ) {
129- const mapping = await setupAndRun ( 'conditional/sameline-alternate' ) ;
124+ const mapping = await setupAndRun ( 'conditional/sameline-alternate' , this . provider ) ;
130125
131126 assert . deepEqual ( mapping [ util . filePath ] . l , {
132127 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -143,7 +138,7 @@ describe('ternary conditionals', () => {
143138 } ) ;
144139
145140 it ( 'should cover a conditional that reaches the consequent (multi-line)' , async function ( ) {
146- const mapping = await setupAndRun ( 'conditional/multiline-consequent' ) ;
141+ const mapping = await setupAndRun ( 'conditional/multiline-consequent' , this . provider ) ;
147142
148143 assert . deepEqual ( mapping [ util . filePath ] . l , {
149144 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -160,7 +155,7 @@ describe('ternary conditionals', () => {
160155 } ) ;
161156
162157 it ( 'should cover a conditional that reaches the alternate (multi-line)' , async function ( ) {
163- const mapping = await setupAndRun ( 'conditional/multiline-alternate' ) ;
158+ const mapping = await setupAndRun ( 'conditional/multiline-alternate' , this . provider ) ;
164159
165160 assert . deepEqual ( mapping [ util . filePath ] . l , {
166161 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -178,7 +173,7 @@ describe('ternary conditionals', () => {
178173
179174 // Runs bool z = (x) ? false : true;
180175 it ( 'should cover a definition assignment by conditional that reaches the alternate' , async function ( ) {
181- const mapping = await setupAndRun ( 'conditional/declarative-exp-assignment-alternate' ) ;
176+ const mapping = await setupAndRun ( 'conditional/declarative-exp-assignment-alternate' , this . provider ) ;
182177
183178 assert . deepEqual ( mapping [ util . filePath ] . l , {
184179 5 : 1 , 6 : 1 , 7 : 1 ,
@@ -196,7 +191,7 @@ describe('ternary conditionals', () => {
196191
197192 // Runs z = (x) ? false : true;
198193 it ( 'should cover an identifier assignment by conditional that reaches the alternate' , async function ( ) {
199- const mapping = await setupAndRun ( 'conditional/identifier-assignment-alternate' ) ;
194+ const mapping = await setupAndRun ( 'conditional/identifier-assignment-alternate' , this . provider ) ;
200195
201196 assert . deepEqual ( mapping [ util . filePath ] . l , {
202197 5 : 1 , 6 : 1 , 7 : 1 , 8 : 1 ,
@@ -213,7 +208,7 @@ describe('ternary conditionals', () => {
213208 } ) ;
214209
215210 it ( 'should cover an assignment to a member expression (reaches the alternate)' , async function ( ) {
216- const mapping = await setupAndRun ( 'conditional/mapping-assignment' ) ;
211+ const mapping = await setupAndRun ( 'conditional/mapping-assignment' , this . provider ) ;
217212
218213 assert . deepEqual ( mapping [ util . filePath ] . l , {
219214 11 : 1 , 12 : 1 ,
0 commit comments