mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9726 from ethereum/arrayCopySol2YulTests
Adding simple array copying tests
This commit is contained in:
commit
5e66583b0b
@ -0,0 +1,11 @@
|
|||||||
|
contract C {
|
||||||
|
uint[] a;
|
||||||
|
function f() public returns (uint, uint) {
|
||||||
|
uint[] memory b = new uint[](3);
|
||||||
|
b[0] = 1;
|
||||||
|
a = b;
|
||||||
|
return (a[0], a.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f() -> 1, 3
|
@ -0,0 +1,10 @@
|
|||||||
|
contract C {
|
||||||
|
uint[] a;
|
||||||
|
function f() public returns (uint, uint) {
|
||||||
|
a.push(1); a.push(0); a.push(0);
|
||||||
|
uint[] memory b = a;
|
||||||
|
return (b[0], b.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f() -> 1, 3
|
@ -0,0 +1,10 @@
|
|||||||
|
contract C {
|
||||||
|
bytes s;
|
||||||
|
function f() external returns (byte) {
|
||||||
|
bytes memory data = "abcd";
|
||||||
|
s = data;
|
||||||
|
return s[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f() -> "a"
|
@ -0,0 +1,9 @@
|
|||||||
|
contract C {
|
||||||
|
bytes s = "abcd";
|
||||||
|
function f() external returns (byte) {
|
||||||
|
bytes memory data = s;
|
||||||
|
return data[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f() -> "a"
|
@ -0,0 +1,9 @@
|
|||||||
|
contract C {
|
||||||
|
bytes s;
|
||||||
|
function f(bytes calldata data) external returns (byte) {
|
||||||
|
s = data;
|
||||||
|
return s[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// f(bytes): 0x20, 0x08, "abcdefgh" -> "a"
|
Loading…
Reference in New Issue
Block a user