Commit 56805303 authored by aniket-engg's avatar aniket-engg Committed by Aniket

0.5.0 contracts integration tests updated

parent 52000695
...@@ -448,18 +448,18 @@ function getFullQuallyfiedFuncDefinitionIdent (contract: ContractDefinitionAstNo ...@@ -448,18 +448,18 @@ function getFullQuallyfiedFuncDefinitionIdent (contract: ContractDefinitionAstNo
function getUnAssignedTopLevelBinOps (subScope: BlockAstNode | IfStatementAstNode | WhileStatementAstNode | ForStatementAstNode): ExpressionStatementAstNode[] { function getUnAssignedTopLevelBinOps (subScope: BlockAstNode | IfStatementAstNode | WhileStatementAstNode | ForStatementAstNode): ExpressionStatementAstNode[] {
let result: ExpressionStatementAstNode[] = [] let result: ExpressionStatementAstNode[] = []
if(subScope.nodeType === 'Block') if(subScope && subScope.nodeType === 'Block')
result = subScope.statements.filter(isBinaryOpInExpression) result = subScope.statements.filter(isBinaryOpInExpression)
// for 'without braces' loops // for 'without braces' loops
else if (subScope && subScope.nodeType && isSubScopeStatement(subScope)) { else if (subScope && subScope.nodeType && isSubScopeStatement(subScope)) {
if (subScope.nodeType === 'IfStatement'){ if (subScope.nodeType === 'IfStatement'){
if((subScope.trueBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.trueBody))) if((subScope.trueBody && subScope.trueBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.trueBody)))
result.push(subScope.trueBody) result.push(subScope.trueBody)
if (subScope.falseBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.falseBody)) if (subScope.falseBody && subScope.falseBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.falseBody))
result.push(subScope.falseBody) result.push(subScope.falseBody)
} }
else { else {
if(subScope.body.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.body)) if(subScope.body && subScope.body.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.body))
result.push(subScope.body) result.push(subScope.body)
} }
} }
...@@ -982,7 +982,7 @@ function isStringToBytesConversion (node: FunctionCallAstNode): boolean { ...@@ -982,7 +982,7 @@ function isStringToBytesConversion (node: FunctionCallAstNode): boolean {
function isExplicitCast (node: FunctionCallAstNode, castFromType: string, castToType: string): boolean { function isExplicitCast (node: FunctionCallAstNode, castFromType: string, castToType: string): boolean {
return node.kind === "typeConversion" && return node.kind === "typeConversion" &&
nodeType(node.expression, exactMatch(nodeTypes.ELEMENTARYTYPENAMEEXPRESSION)) && node.expression.typeName.name === castToType && nodeType(node.expression, exactMatch(nodeTypes.ELEMENTARYTYPENAMEEXPRESSION)) && node.expression.typeName === castToType &&
nodeType(node.arguments[0], exactMatch(nodeTypes.IDENTIFIER)) && typeDescription(node.arguments[0], castFromType) nodeType(node.arguments[0], exactMatch(nodeTypes.IDENTIFIER)) && typeDescription(node.arguments[0], castFromType)
} }
......
// import { default as test} from "tape" import { default as test} from "tape"
// import { helpers } from 'remix-lib' import { helpers } from 'remix-lib'
// import { readFileSync } from 'fs' import { readFileSync } from 'fs'
// import { join } from 'path' import { join } from 'path'
// import { default as StatRunner } from '../../dist/src/solidity-analyzer' import { default as StatRunner } from '../../dist/src/solidity-analyzer'
// import { install, require as requireNPMmodule } from 'npm-install-version' import { install, require as requireNPMmodule } from 'npm-install-version'
// install('solc@0.5.0') install('solc@0.5.0')
// const compiler = requireNPMmodule('solc@0.5.0') const compiler = requireNPMmodule('solc@0.5.0')
// const {compilerInput } = helpers.compiler const {compilerInput } = helpers.compiler
// const folder = 'solidity-v0.5' const folder = 'solidity-v0.5'
// function compile (fileName) { function compile (fileName) {
// const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8') const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
// return JSON.parse(compiler.compile(compilerInput(content))) return JSON.parse(compiler.compile(compilerInput(content)))
// } }
// test('staticAnalysisIssues.functionParameterPassingError', function (t) { test('staticAnalysisIssues.functionParameterPassingError', function (t) {
// // https://github.com/ethereum/remix-ide/issues/889#issuecomment-351746474 // https://github.com/ethereum/remix-ide/issues/889#issuecomment-351746474
// t.plan(2) t.plan(2)
// const res = compile('functionParameters.sol') const res = compile('functionParameters.sol')
// const Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default const Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
// const statRunner = new StatRunner() const statRunner = new StatRunner()
// t.doesNotThrow(() => { t.doesNotThrow(() => {
// statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => { statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
// }) })
// }, 'Analysis should not throw') }, 'Analysis should not throw')
// statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => { statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
// t.ok(!reports.some((mod) => mod.report.some((rep) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) t.ok(!reports.some((mod) => mod.report.some((rep) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
// }) })
// }) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment