aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/test
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-19 08:28:38 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-21 03:19:30 +0800
commit613a78bcf62c10d27d7def8f0ff54efadc2faefb (patch)
tree05e897cec5bb2d26c3a77d4a44597966a54f0dee /packages/sol-cov/test
parentf5decb1d7e8de9a198f1cf1b258a043181ce26d5 (diff)
downloaddexon-0x-contracts-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.gz
dexon-0x-contracts-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.zst
dexon-0x-contracts-613a78bcf62c10d27d7def8f0ff54efadc2faefb.zip
Include source code snippets in revert stack traces
Diffstat (limited to 'packages/sol-cov/test')
-rw-r--r--packages/sol-cov/test/collect_coverage_entries_test.ts17
1 files changed, 5 insertions, 12 deletions
diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-cov/test/collect_coverage_entries_test.ts
index a03be19cd..5eedfd55c 100644
--- a/packages/sol-cov/test/collect_coverage_entries_test.ts
+++ b/packages/sol-cov/test/collect_coverage_entries_test.ts
@@ -6,17 +6,10 @@ import 'mocha';
import * as path from 'path';
import { collectCoverageEntries } from '../src/collect_coverage_entries';
-import { SingleFileSourceRange } from '../src/types';
+import { utils } from '../src/utils';
const expect = chai.expect;
-const getRange = (sourceCode: string, range: SingleFileSourceRange) => {
- const lines = sourceCode.split('\n').slice(range.start.line - 1, range.end.line);
- lines[lines.length - 1] = lines[lines.length - 1].slice(0, range.end.column);
- lines[0] = lines[0].slice(range.start.column);
- return lines.join('\n');
-};
-
describe('Collect coverage entries', () => {
describe('#collectCoverageEntries', () => {
it('correctly collects coverage entries for Simplest contract', () => {
@@ -45,20 +38,20 @@ describe('Collect coverage entries', () => {
const setFunction = `function set(uint x) {
storedData = x;
}`;
- expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction);
+ expect(utils.getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction);
expect(coverageEntries.fnMap[fnIds[1]].name).to.be.equal('get');
// tslint:disable-next-line:custom-no-magic-numbers
expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(8);
const getFunction = `function get() constant returns (uint retVal) {
return storedData;
}`;
- expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[1]].loc)).to.be.equal(getFunction);
+ expect(utils.getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[1]].loc)).to.be.equal(getFunction);
expect(coverageEntries.branchMap).to.be.deep.equal({});
const statementIds = _.keys(coverageEntries.statementMap);
- expect(getRange(simpleStorageContract, coverageEntries.statementMap[statementIds[1]])).to.be.equal(
+ expect(utils.getRange(simpleStorageContract, coverageEntries.statementMap[statementIds[1]])).to.be.equal(
'storedData = x',
);
- expect(getRange(simpleStorageContract, coverageEntries.statementMap[statementIds[3]])).to.be.equal(
+ expect(utils.getRange(simpleStorageContract, coverageEntries.statementMap[statementIds[3]])).to.be.equal(
'return storedData;',
);
expect(coverageEntries.modifiersStatementIds).to.be.deep.equal([]);