@@ -166,6 +166,44 @@ describe('modifiers', () => {
166166 } ) ;
167167 } ) ;
168168
169+ it ( 'should cover when there are post-conditions' , async function ( ) {
170+ const contract = await util . bootstrapCoverage ( 'modifiers/postconditions' , api ) ;
171+ coverage . addContract ( contract . instrumented , util . filePath ) ;
172+
173+ // Both true
174+ await contract . instance . a ( ) ;
175+
176+ // Precondition false
177+ await contract . instance . flip_precondition ( ) ;
178+ try {
179+ await contract . instance . a ( ) ;
180+ } catch ( e ) { /*ignore*/ }
181+
182+ // Reset precondition to true, set postcondition false
183+ await contract . instance . flip_precondition ( ) ;
184+ await contract . instance . flip_postcondition ( ) ;
185+
186+ // Postcondition false
187+ try {
188+ await contract . instance . a ( ) ;
189+ } catch ( e ) { /*ignore*/ }
190+
191+ const mapping = coverage . generate ( contract . data , util . pathPrefix ) ;
192+
193+ assert . deepEqual ( mapping [ util . filePath ] . l , {
194+ 8 :5 , 9 :3 , 10 :3 , 14 :2 , 18 :1 , 22 :3
195+ } ) ;
196+ assert . deepEqual ( mapping [ util . filePath ] . b , {
197+ 1 :[ 3 , 2 ] , 2 :[ 1 , 2 ] , 3 :[ 3 , 2 ] ,
198+ } ) ;
199+ assert . deepEqual ( mapping [ util . filePath ] . s , {
200+ 1 :5 , 2 :3 , 3 :3
201+ } ) ;
202+ assert . deepEqual ( mapping [ util . filePath ] . f , {
203+ 1 :5 , 2 :2 , 3 :1 , 4 :3
204+ } ) ;
205+ } ) ;
206+
169207 // Case: when first modifier always suceeds but a subsequent modifier succeeds and fails,
170208 // there should be a missing `else` branch on first modifier
171209 it ( 'should not be influenced by revert from a subsequent modifier' , async function ( ) {
0 commit comments