mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9347 from ethereum/moretests
Add create & delete array tests for yul
This commit is contained in:
commit
19ec9ecbfd
@ -16,6 +16,7 @@ contract C {
|
||||
return (x[199], y[203][1], z[170].a[1], z[170].b[99]);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> "A", 8, 4, "B"
|
||||
|
17
test/libsolidity/semanticTests/array/delete_memory_array.sol
Normal file
17
test/libsolidity/semanticTests/array/delete_memory_array.sol
Normal file
@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
|
||||
function len() public returns (uint ret) {
|
||||
uint[] memory data = new uint[](2);
|
||||
data[0] = 234;
|
||||
data[1] = 123;
|
||||
delete data;
|
||||
assembly {
|
||||
ret := mload(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// len() -> 0
|
@ -0,0 +1,40 @@
|
||||
contract C {
|
||||
uint[] data;
|
||||
|
||||
function len() public returns (uint ret) {
|
||||
data.push(234);
|
||||
data.push(123);
|
||||
delete data;
|
||||
assembly {
|
||||
ret := sload(data_slot)
|
||||
}
|
||||
}
|
||||
|
||||
function val() public returns (uint ret) {
|
||||
assembly {
|
||||
sstore(0, 2)
|
||||
mstore(0, 0)
|
||||
sstore(keccak256(0, 32), 234)
|
||||
sstore(add(keccak256(0, 32), 1), 123)
|
||||
}
|
||||
|
||||
assert(data[0] == 234);
|
||||
assert(data[1] == 123);
|
||||
|
||||
delete data;
|
||||
|
||||
uint size = 999;
|
||||
|
||||
assembly {
|
||||
size := sload(0)
|
||||
mstore(0, 0)
|
||||
ret := sload(keccak256(0, 32))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// len() -> 0
|
||||
// val() -> 0
|
Loading…
Reference in New Issue
Block a user