monocart-coverage-reports 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Preview Reports
|
|
10
10
|
- [V8](https://cenfun.github.io/monocart-coverage-reports/v8)
|
|
11
|
-
- [V8 Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
|
|
12
11
|
- [V8 Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup)
|
|
13
|
-
- [V8
|
|
12
|
+
- [V8 Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
|
|
13
|
+
- [V8 Node v8 API](https://cenfun.github.io/monocart-coverage-reports/v8-node-api)
|
|
14
14
|
- [V8 Node env](https://cenfun.github.io/monocart-coverage-reports/v8-node-env)
|
|
15
15
|
- [V8 Node Inspector](https://cenfun.github.io/monocart-coverage-reports/v8-node-ins)
|
|
16
16
|
- [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify)
|
|
@@ -108,33 +108,58 @@ const addBranch = (group, node, locationMap, functionInfo) => {
|
|
|
108
108
|
return branchInfo;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
const addNoneBranch = (group) => {
|
|
112
|
+
group.locations.push({
|
|
113
|
+
none: true,
|
|
114
|
+
count: 0
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
111
118
|
// =======================================================================================
|
|
112
119
|
|
|
120
|
+
const hasFunctionBlock = (functionInfo) => {
|
|
121
|
+
const { range } = functionInfo;
|
|
122
|
+
if (range) {
|
|
123
|
+
const { blockMap } = range;
|
|
124
|
+
if (blockMap) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
};
|
|
130
|
+
|
|
113
131
|
const addNodeCount = (node, parents, functionInfo) => {
|
|
114
132
|
|
|
115
133
|
const { start, end } = node;
|
|
116
|
-
const { count, range } = functionInfo;
|
|
117
134
|
|
|
118
|
-
if (
|
|
135
|
+
if (hasFunctionBlock(functionInfo)) {
|
|
136
|
+
const { range } = functionInfo;
|
|
119
137
|
const { blockMap, blockRanges } = range;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const blockItem = findInRanges(start, end, blockRanges);
|
|
130
|
-
if (blockItem) {
|
|
131
|
-
node._state = {
|
|
132
|
-
count: blockItem.count
|
|
133
|
-
};
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
138
|
+
const block = blockMap.get(start);
|
|
139
|
+
if (block) {
|
|
140
|
+
node._state = {
|
|
141
|
+
count: block.count
|
|
142
|
+
};
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
136
145
|
|
|
146
|
+
const blockItem = findInRanges(start, end, blockRanges);
|
|
147
|
+
if (blockItem) {
|
|
148
|
+
node._state = {
|
|
149
|
+
count: blockItem.count
|
|
150
|
+
};
|
|
151
|
+
return;
|
|
137
152
|
}
|
|
153
|
+
|
|
154
|
+
// continue find in reverseParents
|
|
155
|
+
|
|
156
|
+
} else {
|
|
157
|
+
|
|
158
|
+
// default to 1 if no function block
|
|
159
|
+
node._state = {
|
|
160
|
+
count: 1
|
|
161
|
+
};
|
|
162
|
+
return;
|
|
138
163
|
}
|
|
139
164
|
|
|
140
165
|
const reverseParents = [].concat(parents).reverse();
|
|
@@ -149,7 +174,7 @@ const addNodeCount = (node, parents, functionInfo) => {
|
|
|
149
174
|
|
|
150
175
|
// function count
|
|
151
176
|
node._state = {
|
|
152
|
-
count: count
|
|
177
|
+
count: functionInfo.count
|
|
153
178
|
};
|
|
154
179
|
|
|
155
180
|
};
|
|
@@ -198,10 +223,7 @@ const createBranches = (ast, functionInfo, branchMap) => {
|
|
|
198
223
|
addBranch(group, alternate, locationMap, functionInfo);
|
|
199
224
|
} else {
|
|
200
225
|
// add none branch
|
|
201
|
-
group
|
|
202
|
-
none: true,
|
|
203
|
-
count: 0
|
|
204
|
-
});
|
|
226
|
+
addNoneBranch(group);
|
|
205
227
|
// no need update group end, there is no end
|
|
206
228
|
}
|
|
207
229
|
},
|
|
@@ -306,7 +328,7 @@ const LogicalExpression = (group, parentCount, noBlockList, blockCount) => {
|
|
|
306
328
|
|
|
307
329
|
// const start = group.loc.start;
|
|
308
330
|
// if (start > 7874 && start < 7922) {
|
|
309
|
-
// console.log(group.type, parentCount, 'locations', group.locations
|
|
331
|
+
// console.log(group.type, parentCount, 'locations', group.locations);
|
|
310
332
|
// }
|
|
311
333
|
|
|
312
334
|
};
|
|
@@ -351,6 +373,14 @@ const updateBranchCount = (group) => {
|
|
|
351
373
|
const parentCount = getBranchParentCount(reverseParents, functionCount);
|
|
352
374
|
// console.log(functionInfo.start, 'function count', functionCount, 'parent count', parentCount);
|
|
353
375
|
|
|
376
|
+
if (!hasFunctionBlock(functionInfo)) {
|
|
377
|
+
// default to parent if no function range
|
|
378
|
+
locations.forEach((item) => {
|
|
379
|
+
item.count = parentCount;
|
|
380
|
+
});
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
|
|
354
384
|
// calculate branches count
|
|
355
385
|
// > 1
|
|
356
386
|
|
|
@@ -360,9 +390,9 @@ const updateBranchCount = (group) => {
|
|
|
360
390
|
if (item.block) {
|
|
361
391
|
item.count = item.block.count;
|
|
362
392
|
blockCount += item.count;
|
|
363
|
-
|
|
364
|
-
noBlockList.push(item);
|
|
393
|
+
return;
|
|
365
394
|
}
|
|
395
|
+
noBlockList.push(item);
|
|
366
396
|
});
|
|
367
397
|
|
|
368
398
|
const handlers = {
|
|
@@ -227,11 +227,15 @@ const getOriginalStartPosition = (originalText, generatedText, generatedPos) =>
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// ============================
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
230
|
+
// right matched
|
|
231
|
+
|
|
232
|
+
// originalText: "'true' : ",
|
|
233
|
+
// generatedText: '"true" : '
|
|
234
|
+
|
|
235
|
+
const generatedRight = generatedText.slice(generatedPos);
|
|
236
|
+
if (originalText.endsWith(generatedRight)) {
|
|
237
|
+
return originalText.length - generatedRight.length;
|
|
238
|
+
}
|
|
235
239
|
|
|
236
240
|
// ============================
|
|
237
241
|
// starts with original text (few case possible useless)
|
|
@@ -350,7 +354,7 @@ const fixStartColumn = (startMapping, range, state, originalState) => {
|
|
|
350
354
|
|
|
351
355
|
const originalPos = getOriginalStartPosition(originalText, generatedText, generatedPos);
|
|
352
356
|
|
|
353
|
-
// if (originalState.sourcePath.endsWith('
|
|
357
|
+
// if (originalState.sourcePath.endsWith('conditional.js') && range.startOffset === 2153) {
|
|
354
358
|
// console.log('====================================================================');
|
|
355
359
|
// console.log('fix startMapping', originalState.sourcePath);
|
|
356
360
|
// console.log(startMapping);
|
|
@@ -481,12 +485,6 @@ const findStartMapping = (range, state, originalMap) => {
|
|
|
481
485
|
};
|
|
482
486
|
}
|
|
483
487
|
|
|
484
|
-
// if (startMapping.sourceIndex === 1) {
|
|
485
|
-
// console.log('=========================================================');
|
|
486
|
-
// console.log('find next start');
|
|
487
|
-
// console.log(startMapping, nextMapping, range);
|
|
488
|
-
// }
|
|
489
|
-
|
|
490
488
|
// exact and column
|
|
491
489
|
Object.assign(startMapping, nextMapping, {
|
|
492
490
|
exact: true,
|
|
@@ -559,13 +557,10 @@ const findOriginalRange = (range, state, originalMap) => {
|
|
|
559
557
|
const { startMapping, originalState } = startResult;
|
|
560
558
|
|
|
561
559
|
// ==================================================================================
|
|
562
|
-
// if (originalState.sourcePath.endsWith('
|
|
563
|
-
// originalState.
|
|
564
|
-
// console.log('============================================================');
|
|
565
|
-
// console.log(originalState.sourcePath);
|
|
560
|
+
// if (originalState.sourcePath.endsWith('conditional.js') && range.startOffset === 2153) {
|
|
561
|
+
// console.log('============================================================', originalState.sourcePath);
|
|
566
562
|
// console.log(range);
|
|
567
|
-
//
|
|
568
|
-
// originalState.showLog = false;
|
|
563
|
+
// console.log(startMapping);
|
|
569
564
|
// }
|
|
570
565
|
// ==================================================================================
|
|
571
566
|
|