@@ -13,6 +13,7 @@ const {
1313  StringPrototypeIncludes, 
1414  StringPrototypeLocaleCompare, 
1515  StringPrototypeStartsWith, 
16+   MathMax
1617}  =  primordials ; 
1718const  { 
1819  copyFileSync, 
@@ -43,6 +44,7 @@ class CoverageLine {
4344    this . startOffset  =  startOffset ; 
4445    this . endOffset  =  startOffset  +  src . length  -  newlineLength ; 
4546    this . ignore  =  false ; 
47+     this . count  =  0 ; 
4648    this . #covered =  true ; 
4749  } 
4850
@@ -118,6 +120,8 @@ class TestCoverage {
118120      let  totalFunctions  =  0 ; 
119121      let  branchesCovered  =  0 ; 
120122      let  functionsCovered  =  0 ; 
123+       const  functionReports  =  [ ] ; 
124+       const  branchReports  =  [ ] ; 
121125
122126      const  lines  =  ArrayPrototypeMap ( linesWithBreaks ,  ( line ,  i )  =>  { 
123127        const  startOffset  =  offset ; 
@@ -165,6 +169,11 @@ class TestCoverage {
165169          mapRangeToLines ( range ,  lines ) ; 
166170
167171          if  ( isBlockCoverage )  { 
172+             ArrayPrototypePush ( branchReports ,  { 
173+               line : range . lines [ 0 ] . line , 
174+               count : range . count 
175+             } ) ; 
176+ 
168177            if  ( range . count  !==  0  || 
169178                range . ignoredLines  ===  range . lines . length )  { 
170179              branchesCovered ++ ; 
@@ -177,6 +186,12 @@ class TestCoverage {
177186        if  ( j  >  0  &&  ranges . length  >  0 )  { 
178187          const  range  =  ranges [ 0 ] ; 
179188
189+           ArrayPrototypePush ( functionReports ,  { 
190+             name : functions [ j ] . functionName , 
191+             count : MathMax ( ...ArrayPrototypeMap ( ranges ,  r  =>  r . count ) ) , 
192+             line : range . lines [ 0 ] . line 
193+           } ) ; 
194+ 
180195          if  ( range . count  !==  0  ||  range . ignoredLines  ===  range . lines . length )  { 
181196            functionsCovered ++ ; 
182197          } 
@@ -186,15 +201,18 @@ class TestCoverage {
186201      } 
187202
188203      let  coveredCnt  =  0 ; 
189-       const  uncoveredLineNums  =  [ ] ; 
204+       const  lineReports  =  [ ] ; 
190205
191206      for  ( let  j  =  0 ;  j  <  lines . length ;  ++ j )  { 
192207        const  line  =  lines [ j ] ; 
193208
194209        if  ( line . covered  ||  line . ignore )  { 
195210          coveredCnt ++ ; 
211+           if  ( ! line . ignore )  { 
212+             ArrayPrototypePush ( lineReports ,  {  line : line . line ,  count : line . count  } ) 
213+           } 
196214        }  else  { 
197-           ArrayPrototypePush ( uncoveredLineNums ,   line . line ) ; 
215+           ArrayPrototypePush ( lineReports ,   {   line :  line . line ,   count :  0   } ) ; 
198216        } 
199217      } 
200218
@@ -210,7 +228,9 @@ class TestCoverage {
210228        coveredLinePercent : toPercentage ( coveredCnt ,  lines . length ) , 
211229        coveredBranchPercent : toPercentage ( branchesCovered ,  totalBranches ) , 
212230        coveredFunctionPercent : toPercentage ( functionsCovered ,  totalFunctions ) , 
213-         uncoveredLineNumbers : uncoveredLineNums , 
231+         functions : functionReports , 
232+         branches : branchReports , 
233+         lines : lineReports , 
214234      } ) ; 
215235
216236      coverageSummary . totals . totalLineCount  +=  lines . length ; 
@@ -321,6 +341,10 @@ function mapRangeToLines(range, lines) {
321341            endOffset  >=  line . endOffset )  { 
322342          line . covered  =  false ; 
323343        } 
344+         if  ( count  >  0  &&  startOffset  <=  line . startOffset  && 
345+             endOffset  >=  line . endOffset )  { 
346+           line . count  =  count ; 
347+         } 
324348
325349        ArrayPrototypePush ( mappedLines ,  line ) ; 
326350
0 commit comments