From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../@bcoe/v8-coverage/src/lib/compare.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 vanilla/node_modules/@bcoe/v8-coverage/src/lib/compare.js (limited to 'vanilla/node_modules/@bcoe/v8-coverage/src/lib/compare.js') diff --git a/vanilla/node_modules/@bcoe/v8-coverage/src/lib/compare.js b/vanilla/node_modules/@bcoe/v8-coverage/src/lib/compare.js new file mode 100644 index 0000000..d887018 --- /dev/null +++ b/vanilla/node_modules/@bcoe/v8-coverage/src/lib/compare.js @@ -0,0 +1,44 @@ +/** + * Compares two script coverages. + * + * The result corresponds to the comparison of their `url` value (alphabetical sort). + */ +function compareScriptCovs(a, b) { + if (a.url === b.url) { + return 0; + } else if (a.url < b.url) { + return -1; + } else { + return 1; + } +} + +/** + * Compares two function coverages. + * + * The result corresponds to the comparison of the root ranges. + */ +function compareFunctionCovs(a, b) { + return compareRangeCovs(a.ranges[0], b.ranges[0]); +} + +/** + * Compares two range coverages. + * + * The ranges are first ordered by ascending `startOffset` and then by + * descending `endOffset`. + * This corresponds to a pre-order tree traversal. + */ +function compareRangeCovs(a, b) { + if (a.startOffset !== b.startOffset) { + return a.startOffset - b.startOffset; + } else { + return b.endOffset - a.endOffset; + } +} + +module.exports = { + compareScriptCovs, + compareFunctionCovs, + compareRangeCovs, +}; -- cgit v1.2.3