From 2b52677a8264ce69f09c53e1a54b3fd9ed828de3 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Thu, 19 Nov 2020 14:58:43 +0100 Subject: [PATCH] Fixing some calldata to storage tests. --- .../array/copying/array_nested_calldata_to_storage.sol | 10 +++++----- ...f_structs_containing_arrays_calldata_to_storage.sol | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index 279237836..aaeba2ad6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -10,28 +10,28 @@ contract c { a1 = c; assert(a1[0][0] == c[0][0]); assert(a1[0][1] == c[0][1]); - return (a1.length, a1[1][0] + a1[1][1]); + return (a1.length, a1[0][0] + a1[1][1]); } function test2(uint256[][2] calldata c) external returns (uint256, uint256) { a2 = c; assert(a2[0][0] == c[0][0]); assert(a2[0][1] == c[0][1]); - return (a2[0].length, a2[1][0] + a2[1][1]); + return (a2[0].length, a2[0][0] + a2[1][1]); } function test3(uint256[2][] calldata c) external returns (uint256, uint256) { a3 = c; assert(a3[0][0] == c[0][0]); assert(a3[0][1] == c[0][1]); - return (a3.length, a3[1][0] + a3[1][1]); + return (a3.length, a3[0][0] + a3[1][1]); } function test4(uint256[2][2] calldata c) external returns (uint256) { a4 = c; assert(a4[0][0] == c[0][0]); assert(a4[0][1] == c[0][1]); - return (a4[1][0] + a4[1][1]); + return (a4[0][0] + a4[1][1]); } } // ==== @@ -39,5 +39,5 @@ contract c { // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// test3(uint256[2][]): 0x20, 2, 0x40, 0x40, 23, 42 -> 2, 65 +// test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol index dba6af8ef..4aeed91f6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol @@ -9,6 +9,13 @@ contract C { function f(S[] calldata c) external returns (uint256, uint256) { s = c; + assert(s.length == c.length); + for (uint i = 0; i < s.length; i++) { + assert(s[i].a.length == c[i].a.length); + for (uint j = 0; j < s[i].a.length; j++) { + assert(s[i].a[j] == c[i].a[j]); + } + } return (s[1].a.length, s[1].a[0]); } }