12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import { compareFunctionCovs, compareRangeCovs, compareScriptCovs } from "./compare";
- import { RangeTree } from "./range-tree";
- /**
- * Normalizes a process coverage.
- *
- * Sorts the scripts alphabetically by `url`.
- * Reassigns script ids: the script at index `0` receives `"0"`, the script at
- * index `1` receives `"1"` etc.
- * This does not normalize the script coverages.
- *
- * @param processCov Process coverage to normalize.
- */
- export function normalizeProcessCov(processCov) {
- processCov.result.sort(compareScriptCovs);
- for (const [scriptId, scriptCov] of processCov.result.entries()) {
- scriptCov.scriptId = scriptId.toString(10);
- }
- }
- /**
- * Normalizes a process coverage deeply.
- *
- * Normalizes the script coverages deeply, then normalizes the process coverage
- * itself.
- *
- * @param processCov Process coverage to normalize.
- */
- export function deepNormalizeProcessCov(processCov) {
- for (const scriptCov of processCov.result) {
- deepNormalizeScriptCov(scriptCov);
- }
- normalizeProcessCov(processCov);
- }
- /**
- * Normalizes a script coverage.
- *
- * Sorts the function by root range (pre-order sort).
- * This does not normalize the function coverages.
- *
- * @param scriptCov Script coverage to normalize.
- */
- export function normalizeScriptCov(scriptCov) {
- scriptCov.functions.sort(compareFunctionCovs);
- }
- /**
- * Normalizes a script coverage deeply.
- *
- * Normalizes the function coverages deeply, then normalizes the script coverage
- * itself.
- *
- * @param scriptCov Script coverage to normalize.
- */
- export function deepNormalizeScriptCov(scriptCov) {
- for (const funcCov of scriptCov.functions) {
- normalizeFunctionCov(funcCov);
- }
- normalizeScriptCov(scriptCov);
- }
- /**
- * Normalizes a function coverage.
- *
- * Sorts the ranges (pre-order sort).
- * TODO: Tree-based normalization of the ranges.
- *
- * @param funcCov Function coverage to normalize.
- */
- export function normalizeFunctionCov(funcCov) {
- funcCov.ranges.sort(compareRangeCovs);
- const tree = RangeTree.fromSortedRanges(funcCov.ranges);
- normalizeRangeTree(tree);
- funcCov.ranges = tree.toRanges();
- }
- /**
- * @internal
- */
- export function normalizeRangeTree(tree) {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