From 20826e0f08e0e812572aae6b879ea2a9162d93c4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 12 Mar 2018 12:56:22 +0100 Subject: Add an explanatory comment for making ranges unique --- packages/sol-cov/src/coverage_manager.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/sol-cov/src') diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index b70ca6f3f..9b812446a 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -42,6 +42,7 @@ export class CoverageManager { const coverageEntriesDescription = collectCoverageEntries(contractData.sourceCodes[fileIndex], fileName); let sourceRanges = _.map(coveredPcs, coveredPc => pcToSourceRange[coveredPc]); sourceRanges = _.compact(sourceRanges); // Some PC's don't map to a source range and we just ignore them. + // By default lodash does a shallow object comparasion. We JSON.stringify them and compare as strings. sourceRanges = _.uniqBy(sourceRanges, s => JSON.stringify(s)); // We don't care if one PC was covered multiple times within a single transaction sourceRanges = _.filter(sourceRanges, sourceRange => sourceRange.fileName === fileName); const branchCoverage: BranchCoverage = {}; -- cgit