Code coverage for Solidity smart-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
solidity-coverage/test/function.js

40 lines
1.6 KiB

/* eslint-env node, mocha */
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
/**
* NB: passing '1' to solc as an option activates the optimiser
* NB: solc will throw if there is a compilation error, causing the test to fail
* and passing the error to mocha.
*/
describe('function declarations', () => {
it('should compile after instrumenting an ordinary function declaration', () => {
const contract = util.getCode('function/function.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting an abstract function declaration', () => {
const contract = util.getCode('function/abstract.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting a function declaration with an empty body', () => {
const contract = util.getCode('function/empty-body.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting lots of declarations in row', () => {
const contract = util.getCode('function/multiple.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
});