commit
db2ab025c7
@ -0,0 +1,32 @@ |
||||
/* eslint-env node, mocha */ |
||||
/* global artifacts, contract, assert */ |
||||
|
||||
const TotallyPure = artifacts.require('./TotallyPure.sol'); |
||||
|
||||
contract('TotallyPure', accounts => { |
||||
|
||||
it('calls imported, inherited pure/view functions within its own function', async function(){ |
||||
const instance = await TotallyPure.deployed(); |
||||
await instance.usesThem(); |
||||
}); |
||||
|
||||
it('calls an imported, inherited pure function', async function(){ |
||||
const instance = await TotallyPure.deployed(); |
||||
const value = await instance.isPure(4,5); |
||||
}); |
||||
|
||||
it('calls an importend, inherited view function', async function(){ |
||||
const instance = await TotallyPure.deployed(); |
||||
const value = await instance.isView(); |
||||
}) |
||||
|
||||
it('overrides an imported, inherited abstract pure function', async function(){ |
||||
const instance = await TotallyPure.deployed(); |
||||
const value = await instance.bePure(4,5); |
||||
}) |
||||
|
||||
it('overrides an imported, inherited abstract view function', async function(){ |
||||
const instance = await TotallyPure.deployed(); |
||||
const value = await instance.beView(); |
||||
}); |
||||
}); |
@ -0,0 +1,28 @@ |
||||
pragma experimental "v0.5.0"; |
||||
|
||||
import "./../assets/PureView.sol"; |
||||
|
||||
contract TotallyPure is PureView { |
||||
uint onehundred = 99; |
||||
|
||||
function usesThem() { |
||||
uint y = isPure(1,2); |
||||
uint z = isView(); |
||||
} |
||||
|
||||
function isPure(uint a, uint b) pure returns (uint){ |
||||
return a * b; |
||||
} |
||||
|
||||
function isView() view returns (uint){ |
||||
return notpureview; |
||||
} |
||||
|
||||
function bePure(uint a, uint b) pure returns (uint) { |
||||
return a + b; |
||||
} |
||||
|
||||
function beView() view returns (uint){ |
||||
return onehundred; |
||||
} |
||||
} |
Loading…
Reference in new issue