aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/test/collect_coverage_entries_test.ts
diff options
context:
space:
mode:
authorperissology <perissology@protonmail.com>2018-06-25 23:18:02 +0800
committerperissology <perissology@protonmail.com>2018-06-25 23:18:02 +0800
commit92cb9c3807917049b392d86160e7d88f73a5c7b4 (patch)
tree5ec2d589394dcfa1db7800d1d35978d87b4f9ae4 /packages/sol-cov/test/collect_coverage_entries_test.ts
parent1a4e99431bf0cfc8c5db2235a935d62ebb8469b2 (diff)
downloaddexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar.gz
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar.bz2
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar.lz
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar.xz
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.tar.zst
dexon-sol-tools-92cb9c3807917049b392d86160e7d88f73a5c7b4.zip
add /*solcov ignore next*/ tests
Diffstat (limited to 'packages/sol-cov/test/collect_coverage_entries_test.ts')
-rw-r--r--packages/sol-cov/test/collect_coverage_entries_test.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-cov/test/collect_coverage_entries_test.ts
index f88f3b3c3..7832ec316 100644
--- a/packages/sol-cov/test/collect_coverage_entries_test.ts
+++ b/packages/sol-cov/test/collect_coverage_entries_test.ts
@@ -121,5 +121,35 @@ describe('Collect coverage entries', () => {
const branchTypes = _.map(branchDescriptions, branchDescription => branchDescription.type);
expect(branchTypes).to.be.deep.equal(['if', 'if', 'if', 'if', 'binary-expr', 'if']);
});
+
+ it('correctly ignores all coverage entries for Ignore contract', () => {
+ const solcovIgnoreContractBaseName = 'SolcovIgnore.sol';
+ const solcovIgnoreContractFileName = path.resolve(
+ __dirname,
+ 'fixtures/contracts',
+ solcovIgnoreContractBaseName,
+ );
+ const solcovIgnoreContract = fs.readFileSync(solcovIgnoreContractFileName).toString();
+ const coverageEntries = collectCoverageEntries(solcovIgnoreContract);
+ const fnIds = _.keys(coverageEntries.fnMap);
+
+ expect(fnIds.length).to.be.equal(1);
+ expect(coverageEntries.fnMap[fnIds[0]].name).to.be.equal('set');
+ // tslint:disable-next-line:custom-no-magic-numbers
+ expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(6);
+ const setFunction = `function set(uint x) public {
+ /* solcov ignore next */
+ storedData = x;
+ }`;
+ expect(utils.getRange(solcovIgnoreContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction);
+
+ expect(coverageEntries.branchMap).to.be.deep.equal({});
+ const statementIds = _.keys(coverageEntries.statementMap);
+ expect(utils.getRange(solcovIgnoreContract, coverageEntries.statementMap[statementIds[0]])).to.be.equal(
+ setFunction,
+ );
+ expect(statementIds.length).to.be.equal(1);
+ expect(coverageEntries.modifiersStatementIds.length).to.be.equal(0);
+ });
});
});