solidity/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol

24 lines
888 B
Solidity

contract C {
uint[] storageArray;
function test_boundary_check(uint256 len, uint256 access) public returns (uint256)
{
while(storageArray.length < len)
storageArray.push();
while(storageArray.length > len)
storageArray.pop();
return storageArray[access];
}
}
// ====
// compileViaYul: true
// ----
// test_boundary_check(uint256, uint256): 10, 11 -> FAILURE
// test_boundary_check(uint256, uint256): 10, 9 -> 0
// test_boundary_check(uint256, uint256): 1, 9 -> FAILURE
// test_boundary_check(uint256, uint256): 1, 1 -> FAILURE
// test_boundary_check(uint256, uint256): 10, 10 -> FAILURE
// test_boundary_check(uint256, uint256): 256, 256 -> FAILURE
// test_boundary_check(uint256, uint256): 256, 255 -> 0
// test_boundary_check(uint256, uint256): 256, 0xFFFF -> FAILURE
// test_boundary_check(uint256, uint256): 256, 2 -> 0