mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Moving some more array tests to semanticTests.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
contract c {
|
||||
bytes data;
|
||||
function direct(bytes calldata arg, uint index) external returns (uint) {
|
||||
return uint(uint8(arg[index]));
|
||||
}
|
||||
function storageCopyRead(bytes calldata arg, uint index) external returns (uint) {
|
||||
data = arg;
|
||||
return uint(uint8(data[index]));
|
||||
}
|
||||
function storageWrite() external returns (uint) {
|
||||
data = new bytes(35);
|
||||
data[31] = 0x77;
|
||||
data[32] = 0x14;
|
||||
|
||||
data[31] = 0x01;
|
||||
data[31] |= 0x08;
|
||||
data[30] = 0x01;
|
||||
data[32] = 0x03;
|
||||
return uint(uint8(data[30])) * 0x100 | uint(uint8(data[31])) * 0x10 | uint(uint8(data[32]));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// direct(bytes,uint256): 0x40, 33, 34, 0x000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F, left(0x2021) -> 0x21
|
||||
// storageCopyRead(bytes,uint256): 0x40, 33, 34, 0x000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F, left(0x2021) -> 0x21
|
||||
// storageWrite() -> 0x193
|
||||
@@ -0,0 +1,17 @@
|
||||
contract Main {
|
||||
function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) {
|
||||
c1 = _s1[i1];
|
||||
c2 = intern(_s1, i2);
|
||||
c3 = internIndirect(_s1)[i3];
|
||||
}
|
||||
function intern(bytes memory _s1, uint i) public returns (byte c) {
|
||||
return _s1[i];
|
||||
}
|
||||
function internIndirect(bytes memory _s1) public returns (bytes memory) {
|
||||
return _s1;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes,uint256,uint256,uint256): 0x80, 3, 4, 5, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> "d", "e", "f"
|
||||
Reference in New Issue
Block a user