solidity/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol
Alex Beregszaszi 0b6f87ef3c Update tests
2021-05-31 10:43:18 +01:00

27 lines
568 B
Solidity

contract c {
uint[20] spacer;
uint[] dynamic;
function fill() public {
for (uint i = 0; i < 21; ++i)
dynamic.push(i + 1);
}
function halfClear() public {
while (dynamic.length > 5)
dynamic.pop();
}
function fullClear() public { delete dynamic; }
}
// ====
// compileViaYul: also
// ----
// storageEmpty -> 1
// fill() ->
// gas irOptimized: 520998
// gas legacy: 521768
// gas legacyOptimized: 517043
// storageEmpty -> 0
// halfClear() ->
// storageEmpty -> 0
// fullClear() ->
// storageEmpty -> 1