diff --git a/test/libsolidity/semanticTests/array/array_copy_memory_to_storage.sol b/test/libsolidity/semanticTests/array/array_copy_memory_to_storage.sol new file mode 100644 index 000000000..3055b0fa8 --- /dev/null +++ b/test/libsolidity/semanticTests/array/array_copy_memory_to_storage.sol @@ -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 diff --git a/test/libsolidity/semanticTests/array/array_copy_storage_to_memory.sol b/test/libsolidity/semanticTests/array/array_copy_storage_to_memory.sol new file mode 100644 index 000000000..8bc6b86a2 --- /dev/null +++ b/test/libsolidity/semanticTests/array/array_copy_storage_to_memory.sol @@ -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 diff --git a/test/libsolidity/semanticTests/array/bytes_memory_to_storage.sol b/test/libsolidity/semanticTests/array/bytes_memory_to_storage.sol new file mode 100644 index 000000000..eebdb7e9b --- /dev/null +++ b/test/libsolidity/semanticTests/array/bytes_memory_to_storage.sol @@ -0,0 +1,10 @@ +contract C { + bytes s; + function f() external returns (byte) { + bytes memory data = "abcd"; + s = data; + return s[0]; + } +} +// ---- +// f() -> "a" diff --git a/test/libsolidity/semanticTests/array/bytes_storage_to_memory.sol b/test/libsolidity/semanticTests/array/bytes_storage_to_memory.sol new file mode 100644 index 000000000..13932a2cc --- /dev/null +++ b/test/libsolidity/semanticTests/array/bytes_storage_to_memory.sol @@ -0,0 +1,9 @@ +contract C { + bytes s = "abcd"; + function f() external returns (byte) { + bytes memory data = s; + return data[0]; + } +} +// ---- +// f() -> "a" diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_to_storage.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_storage.sol new file mode 100644 index 000000000..07041910d --- /dev/null +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_storage.sol @@ -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"