Update comment tests

test/vm-fixtures
cgewecke 5 years ago
parent 8dccb52225
commit 43f0abc068
  1. 4
      test/soliditySources/contracts/comments/postFunctionDeclarationComment.sol
  2. 40
      test/units/comments.js
  3. 1
      test/util/util.js

@ -3,5 +3,7 @@ pragma solidity ^0.5.0;
contract Test { contract Test {
function a(bool test) public {//Comment immediately after function declaration function a(bool test) public {//Comment immediately after function declaration
} }
function b(bool test) public {uint8 x=1;}//Comment immediately after function closes function b(bool test) public {
uint8 x=1;
}//Comment immediately after function closes
} }

@ -1,38 +1,26 @@
/* eslint-env node, mocha */
/*const path = require('path');
const getInstrumentedVersion = require('./../lib/instrumentSolidity.js');
const util = require('./util/util.js');
const solc = require('solc');
const assert = require('assert'); const assert = require('assert');
const util = require('./../util/util.js');
describe('comments', () => { describe('comments', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should cover functions even if comments are present immediately after the opening {', () => { it('should cover functions even if comments are present immediately after the opening {', () => {
const contract = util.getCode('comments/postFunctionDeclarationComment.sol'); const info = util.instrumentAndCompile('comments/postFunctionDeclarationComment');
const info = getInstrumentedVersion(contract, filePath); util.report(info.solcOutput.errors);
const output = JSON.parse(solc.compile(util.codeToCompilerInput(info.contract)));
util.report(output.errors);
}); });
it('should cover lines even if comments are present', () => { it('should cover lines even if comments are present', () => {
const contract = util.getCode('comments/postLineComment.sol'); const info = util.instrumentAndCompile('comments/postLineComment');
const info = getInstrumentedVersion(contract, filePath); assert.deepEqual([6, 5], info.instrumented.runnableLines);
const output = JSON.parse(solc.compile(util.codeToCompilerInput(info.contract))); util.report(info.solcOutput.errors);
assert.deepEqual([6, 5], info.runnableLines);
util.report(output.errors);
}); });
it('should cover contracts even if comments are present', () => { it('should cover contracts even if comments are present', () => {
const contract = util.getCode('comments/postContractComment.sol'); const info = util.instrumentAndCompile('comments/postContractComment');
const info = getInstrumentedVersion(contract, filePath); util.report(info.solcOutput.errors);
const output = JSON.parse(solc.compile(util.codeToCompilerInput(info.contract)));
util.report(output.errors);
}); });
it('should cover if statements even if comments are present immediately after opening { ', () => { it('should cover if statements even if comments are present immediately after opening { ', () => {
const contract = util.getCode('comments/postIfStatementComment.sol'); const info = util.instrumentAndCompile('comments/postIfStatementComment');
const info = getInstrumentedVersion(contract, filePath); util.report(info.solcOutput.errors);
const output = JSON.parse(solc.compile(util.codeToCompilerInput(info.contract)));
util.report(output.errors);
}); });
});*/ });

@ -59,6 +59,7 @@ function instrumentAndCompile(sourceName) {
const contract = getCode(`${sourceName}.sol`) const contract = getCode(`${sourceName}.sol`)
const instrumenter = new Instrumenter(); const instrumenter = new Instrumenter();
const instrumented = instrumenter.instrument(contract, filePath); const instrumented = instrumenter.instrument(contract, filePath);
return { return {
contract: contract, contract: contract,
instrumented: instrumented, instrumented: instrumented,

Loading…
Cancel
Save