solidity/test/libsolidity/semanticTests/various/address_code.sol

26 lines
742 B
Solidity
Raw Normal View History

2020-09-24 16:28:14 +00:00
contract C {
bytes public initCode;
constructor() {
// This should catch problems, but lets also test the case the optimiser is buggy.
assert(address(this).code.length == 0);
initCode = address(this).code;
}
// To avoid dependency on exact length.
function f() public view returns (bool) { return address(this).code.length > 400; }
function g() public view returns (uint) { return address(0).code.length; }
function h() public view returns (uint) { return address(1).code.length; }
}
// ====
2021-04-23 15:59:01 +00:00
// compileToEwasm: also
2020-09-24 16:28:14 +00:00
// ----
// constructor() ->
2022-05-23 10:54:18 +00:00
// gas irOptimized: 177507
2022-06-07 12:45:10 +00:00
// gas legacy: 249207
// gas legacyOptimized: 157489
2020-09-24 16:28:14 +00:00
// initCode() -> 0x20, 0
// f() -> true
// g() -> 0
// h() -> 0