Skip to content

Commit

Permalink
Static Analysis: more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Fröwis authored and chriseth committed May 17, 2017
1 parent f9f0381 commit b8e2db2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/staticanalysis/staticAnalysisCommon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ test('staticAnalysisCommon.getSuperLocalCallName', function (t) {
],
'name': 'MemberAccess'
}

test('staticAnalysisCommon.getExternalDirectCallContractName', function (t) {
t.plan(3)
var localCall = {
'attributes': {
'type': 'tuple()',
Expand Down Expand Up @@ -520,6 +523,7 @@ test('staticAnalysisCommon.getExternalDirectCallContractName', function (t) {
name: 'MemberAccess',
src: '405:6:0'
}

t.ok(common.getExternalDirectCallContractName(externalDirect) === 'InfoFeed', 'external direct call contract name from node')
t.throws(() => common.getExternalDirectCallContractName(thisLocalCall), undefined, 'throws on other nodes')
t.throws(() => common.getExternalDirectCallContractName(localCall), undefined, 'throws on other nodes')
Expand Down Expand Up @@ -811,6 +815,7 @@ test('staticAnalysisCommon.getStateVariableDeclarationsFormContractNode', functi
'name': 'ContractDefinition'
}
var res = common.getStateVariableDeclarationsFormContractNode(contract).map(common.getDeclaredVariableName)

t.ok(res[0] === 'chairperson', 'var 1 should be ')
t.ok(res[1] === 'voters', 'var 2 should be ')
t.ok(res[2] === 'proposals', 'var 3 should be ')
Expand Down Expand Up @@ -1192,6 +1197,7 @@ test('staticAnalysisCommon.isBuiltinFunctionCall', function (t) {
t.notOk(common.isBuiltinFunctionCall(localCall), 'local call is not builtin')
})


test('staticAnalysisCommon.isStorageVariableDeclaration', function (t) {
t.plan(3)
var node1 = {
Expand Down Expand Up @@ -1713,6 +1719,7 @@ test('staticAnalysisCommon.isBlockTimestampAccess', function (t) {
t.notOk(common.isNowAccess(node), 'is now used should not work')
})

<<<<<<< 1ca54743848c4b5087105325dbc095c1b6a8b428
test('staticAnalysisCommon.isBlockBlockhashAccess', function (t) {
t.plan(4)
var node = {
Expand Down

0 comments on commit b8e2db2

Please sign in to comment.