solidity/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol
2020-03-19 14:42:25 +01:00

35 lines
594 B
Solidity

contract Flow {
bool public success;
mapping(address => function() internal) stages;
function stage0() internal {
stages[msg.sender] = stage1;
}
function stage1() internal {
stages[msg.sender] = stage2;
}
function stage2() internal {
success = true;
}
constructor() public {
stages[msg.sender] = stage0;
}
function f() public returns (uint256) {
stages[msg.sender]();
return 7;
}
}
// ----
// success() -> false
// f() -> 7
// f() -> 7
// success() -> false
// f() -> 7
// success() -> true