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.
59 lines
2.0 KiB
59 lines
2.0 KiB
7 years ago
|
/* eslint-env node, mocha */
|
||
|
/* global artifacts, contract, assert */
|
||
|
|
||
|
const TotallyPure = artifacts.require('./TotallyPure.sol');
|
||
|
|
||
|
contract('TotallyPure', accounts => {
|
||
7 years ago
|
it('calls imported, inherited pure/view functions within its own function', async () => {
|
||
7 years ago
|
const instance = await TotallyPure.deployed();
|
||
|
await instance.usesThem();
|
||
|
});
|
||
|
|
||
7 years ago
|
it('calls an imported, inherited pure function', async () => {
|
||
7 years ago
|
const instance = await TotallyPure.deployed();
|
||
7 years ago
|
const value = await instance.isPure(4, 5);
|
||
7 years ago
|
assert.equal(value.toNumber(), 20);
|
||
7 years ago
|
});
|
||
|
|
||
7 years ago
|
it('calls an imported, inherited view function', async () => {
|
||
7 years ago
|
const instance = await TotallyPure.deployed();
|
||
7 years ago
|
const value = await instance.isView();
|
||
7 years ago
|
assert.equal(value.toNumber(), 5);
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
it('overrides an imported, inherited abstract pure function', async () => {
|
||
7 years ago
|
const instance = await TotallyPure.deployed();
|
||
7 years ago
|
const value = await instance.bePure(4, 5);
|
||
7 years ago
|
assert.equal(value.toNumber(), 9);
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
it('overrides an imported, inherited abstract view function', async () => {
|
||
7 years ago
|
const instance = await TotallyPure.deployed();
|
||
7 years ago
|
const value = await instance.beView();
|
||
7 years ago
|
assert.equal(value.toNumber(), 99);
|
||
7 years ago
|
});
|
||
7 years ago
|
|
||
7 years ago
|
it('calls a pure method implemented in an inherited class', async() => {
|
||
|
const instance = await TotallyPure.deployed();
|
||
|
const value = await instance.inheritedPure(4, 5);
|
||
|
assert.equal(value.toNumber(), 9);
|
||
|
});
|
||
|
|
||
|
it('calls a view method implemented in an inherited class', async () => {
|
||
|
const instance = await TotallyPure.deployed();
|
||
|
const value = await instance.inheritedView();
|
||
|
assert.equal(value.toNumber(), 5);
|
||
|
});
|
||
|
|
||
7 years ago
|
it('calls a view method whose modifiers span lines', async () => {
|
||
|
const instance = await TotallyPure.deployed();
|
||
|
const value = await instance.multiline(5, 7)
|
||
|
assert.equal(value.toNumber(), 99);
|
||
|
});
|
||
7 years ago
|
|
||
|
it('calls a method who signature is defined by an interface', async () => {
|
||
|
const instance = await TotallyPure.deployed();
|
||
|
await instance.cry();
|
||
|
});
|
||
|
|
||
7 years ago
|
});
|