solidity/test/libsolidity/semanticTests/intheritance/value_for_constructor.sol
2020-05-19 17:42:19 +02:00

48 lines
893 B
Solidity

contract Helper {
bytes3 name;
bool flag;
constructor(bytes3 x, bool f) public payable {
name = x;
flag = f;
}
function getName() public returns (bytes3 ret) {
return name;
}
function getFlag() public returns (bool ret) {
return flag;
}
}
contract Main {
Helper h;
constructor() public payable {
h = (new Helper){value: 10}("abc", true);
}
function getFlag() public returns (bool ret) {
return h.getFlag();
}
function getName() public returns (bytes3 ret) {
return h.getName();
}
function getBalances() public returns (uint256 me, uint256 them) {
me = address(this).balance;
them = address(h).balance;
}
}
// ====
// compileViaYul: also
// ----
// constructor(), 22 wei ->
// getFlag() -> true
// getName() -> "abc"
// getBalances() -> 12, 10