mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adds some more tests and groups all function call inheritance related together into single sub-directory.
This commit is contained in:
parent
b0acf5dc86
commit
8ac0bee361
@ -0,0 +1,13 @@
|
|||||||
|
contract Base {
|
||||||
|
function f(uint n) public returns (uint) {
|
||||||
|
return 2 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function g(uint n) public returns (uint) {
|
||||||
|
return f(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// g(uint256): 4 -> 8
|
@ -0,0 +1,27 @@
|
|||||||
|
contract BaseBase {
|
||||||
|
function f(uint n) public virtual returns (uint) {
|
||||||
|
return 2 * n;
|
||||||
|
}
|
||||||
|
function s(uint n) public returns (uint) {
|
||||||
|
return 4 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Base is BaseBase {
|
||||||
|
function f(uint n) public virtual override returns (uint) {
|
||||||
|
return 3 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function g(uint n) public returns (uint) {
|
||||||
|
return f(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function h(uint n) public returns (uint) {
|
||||||
|
return s(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// g(uint256): 4 -> 12
|
||||||
|
// h(uint256): 4 -> 16
|
@ -0,0 +1,30 @@
|
|||||||
|
contract BaseBase {
|
||||||
|
function f(uint n) public virtual returns (uint) {
|
||||||
|
return 2 * n;
|
||||||
|
}
|
||||||
|
|
||||||
|
function s(uint n) public returns (uint) {
|
||||||
|
return 4 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Base is BaseBase {
|
||||||
|
function f(uint n) public virtual override returns (uint) {
|
||||||
|
return 3 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function g(uint n) public returns (uint) {
|
||||||
|
// calling base-bse function of a virtual overridden function.
|
||||||
|
return BaseBase.f(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function k(uint n) public returns (uint) {
|
||||||
|
// Calling base-base function of a non-virtual function.
|
||||||
|
return BaseBase.s(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// g(uint256): 4 -> 8
|
||||||
|
// k(uint256): 4 -> 16
|
@ -0,0 +1,14 @@
|
|||||||
|
contract Base {
|
||||||
|
function f(uint n) public returns (uint) {
|
||||||
|
return 2 * n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function g(uint n) public returns (uint) {
|
||||||
|
return Base.f(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// g(uint256): 4 -> 8
|
||||||
|
|
Loading…
Reference in New Issue
Block a user