Repository navigation
38 lines (38 loc) · 1.68 KB
Copy path
File metadata and controls
38 lines (38 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/dist/index.mjs b/dist/index.mjs
index ebe37dd027ab90208d32131aa5e114ce9c9124b0..28b2332fd37e5bd6d08cf1e385804f8ff7bd076f 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -526,6 +526,22 @@ var y = class CoverageMapper {
let i = [], a = [];
for (let e of n) {
if (!e) {
+ let e = getCount({
+ startOffset: t.start + this.wrapperLength,
+ endOffset: t.end + this.wrapperLength
+ }, this.ranges), n = a.at(-1) || 0;
+ // An unlocatable path (`if` with no `else`, `switch` with no `default`) is
+ // "the count of the region the node covers, minus the located paths". Inside
+ // an `async` function that difference is not the path's count: V8 records the
+ // statements after an `await` (e.g. after `x ?? await p()`) as a continuation
+ // block counted for the awaited path only, while a block taken by the callers
+ // that skipped the await is counted on that other path. A located path can
+ // then out-count the region said to contain it, and the subtraction goes
+ // negative -- a count no execution can produce. The entry count of the node
+ // is not recoverable from such a record, so publish the branch with only its
+ // located paths instead of an impossible counter; this is also exactly what
+ // the reference v8-to-istanbul converter emits for the same input.
+ if (e - n < 0) continue;
i.push({
start: {
line: void 0,
@@ -536,10 +552,6 @@ var y = class CoverageMapper {
column: void 0
}
});
- let e = getCount({
- startOffset: t.start + this.wrapperLength,
- endOffset: t.end + this.wrapperLength
- }, this.ranges), n = a.at(-1) || 0;
a.push(e - n);
continue;
}