mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update tests
This commit is contained in:
parent
e3b6c5a4bd
commit
b000a022f2
@ -132,7 +132,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reserve(string _name) external payable {
|
function reserve(string calldata _name) external payable {
|
||||||
if (bytes(_name).length == 0)
|
if (bytes(_name).length == 0)
|
||||||
revert();
|
revert();
|
||||||
bool needAuction = requiresAuction(_name);
|
bool needAuction = requiresAuction(_name);
|
||||||
|
@ -348,7 +348,7 @@ contract multisig {
|
|||||||
|
|
||||||
// TODO: document
|
// TODO: document
|
||||||
function changeOwner(address _from, address _to) external;
|
function changeOwner(address _from, address _to) external;
|
||||||
function execute(address _to, uint _value, bytes _data) external returns (bytes32);
|
function execute(address _to, uint _value, bytes calldata _data) external returns (bytes32);
|
||||||
function confirm(bytes32 _h) public returns (bool);
|
function confirm(bytes32 _h) public returns (bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ contract Wallet is multisig, multiowned, daylimit {
|
|||||||
// If not, goes into multisig process. We provide a hash on return to allow the sender to provide
|
// If not, goes into multisig process. We provide a hash on return to allow the sender to provide
|
||||||
// shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
|
// shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
|
||||||
// and _data arguments). They still get the option of using them if they want, anyways.
|
// and _data arguments). They still get the option of using them if they want, anyways.
|
||||||
function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) {
|
function execute(address _to, uint _value, bytes calldata _data) external onlyowner returns (bytes32 _r) {
|
||||||
// first, take the opportunity to check that we're under the daily limit.
|
// first, take the opportunity to check that we're under the daily limit.
|
||||||
if (underLimit(_value)) {
|
if (underLimit(_value)) {
|
||||||
emit SingleTransact(msg.sender, _value, _to, _data);
|
emit SingleTransact(msg.sender, _value, _to, _data);
|
||||||
|
@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(byte_arrays)
|
|||||||
return (a, b.length, b[3], c);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f_external(uint a, bytes b, uint c)
|
function f_external(uint a, bytes calldata b, uint c)
|
||||||
external pure returns (uint, uint, byte, uint) {
|
external pure returns (uint, uint, byte, uint) {
|
||||||
return (a, b.length, b[3], c);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(calldata_arrays_too_large)
|
|||||||
{
|
{
|
||||||
string sourceCode = R"(
|
string sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint a, uint[] b, uint c) external pure returns (uint) {
|
function f(uint a, uint[] calldata b, uint c) external pure returns (uint) {
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(calldata)
|
|||||||
string sourceCode = R"(
|
string sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
event E(bytes);
|
event E(bytes);
|
||||||
function f(bytes a) external {
|
function f(bytes calldata a) external {
|
||||||
emit E(a);
|
emit E(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ BOOST_AUTO_TEST_CASE(strings_and_arrays)
|
|||||||
// bug #1801
|
// bug #1801
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f(string a, bytes b, uint[] c) external {}
|
function f(string calldata a, bytes calldata b, uint[] calldata c) external {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ BOOST_AUTO_TEST_CASE(array_multiple_local_vars)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f(uint256[] seq) external pure returns (uint256) {
|
function f(uint256[] calldata seq) external pure returns (uint256) {
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
uint sum = 0;
|
uint sum = 0;
|
||||||
while (i < seq.length)
|
while (i < seq.length)
|
||||||
@ -4540,7 +4540,7 @@ BOOST_AUTO_TEST_CASE(struct_containing_bytes_copy_and_delete)
|
|||||||
struct Struct { uint a; bytes data; uint b; }
|
struct Struct { uint a; bytes data; uint b; }
|
||||||
Struct data1;
|
Struct data1;
|
||||||
Struct data2;
|
Struct data2;
|
||||||
function set(uint _a, bytes _data, uint _b) external returns (bool) {
|
function set(uint _a, bytes calldata _data, uint _b) external returns (bool) {
|
||||||
data1.a = _a;
|
data1.a = _a;
|
||||||
data1.b = _b;
|
data1.b = _b;
|
||||||
data1.data = _data;
|
data1.data = _data;
|
||||||
@ -4764,12 +4764,12 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
|
|||||||
}
|
}
|
||||||
library L {
|
library L {
|
||||||
struct S { uint b; uint a; }
|
struct S { uint b; uint a; }
|
||||||
function f() public pure returns (S) {
|
function f() public pure returns (S memory) {
|
||||||
S memory s;
|
S memory s;
|
||||||
s.a = 3;
|
s.a = 3;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
function g() public pure returns (I.S) {
|
function g() public pure returns (I.S memory) {
|
||||||
I.S memory s;
|
I.S memory s;
|
||||||
s.a = 4;
|
s.a = 4;
|
||||||
return s;
|
return s;
|
||||||
@ -4779,25 +4779,25 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
|
|||||||
function a(S memory) public pure returns (uint) { return 2; }
|
function a(S memory) public pure returns (uint) { return 2; }
|
||||||
}
|
}
|
||||||
contract C is I {
|
contract C is I {
|
||||||
function f() public pure returns (S) {
|
function f() public pure returns (S memory) {
|
||||||
S memory s;
|
S memory s;
|
||||||
s.a = 1;
|
s.a = 1;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
function g() public pure returns (I.S) {
|
function g() public pure returns (I.S memory) {
|
||||||
I.S memory s;
|
I.S memory s;
|
||||||
s.a = 2;
|
s.a = 2;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
function h() public pure returns (L.S) {
|
function h() public pure returns (L.S memory) {
|
||||||
L.S memory s;
|
L.S memory s;
|
||||||
s.a = 5;
|
s.a = 5;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
function x() public pure returns (L.S) {
|
function x() public pure returns (L.S memory) {
|
||||||
return L.f();
|
return L.f();
|
||||||
}
|
}
|
||||||
function y() public pure returns (I.S) {
|
function y() public pure returns (I.S memory) {
|
||||||
return L.g();
|
return L.g();
|
||||||
}
|
}
|
||||||
function a1() public pure returns (uint) { S memory s; return L.a(s); }
|
function a1() public pure returns (uint) { S memory s; return L.a(s); }
|
||||||
@ -4941,7 +4941,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments)
|
|||||||
uint result;
|
uint result;
|
||||||
function f(uint a, uint b) public { result += a + b; }
|
function f(uint a, uint b) public { result += a + b; }
|
||||||
function g(uint a) public { result *= a; }
|
function g(uint a) public { result *= a; }
|
||||||
function test(uint a, bytes data1, bytes data2, uint b) external returns (uint r_a, uint r, uint r_b, uint l) {
|
function test(uint a, bytes calldata data1, bytes calldata data2, uint b) external returns (uint r_a, uint r, uint r_b, uint l) {
|
||||||
r_a = a;
|
r_a = a;
|
||||||
address(this).call(data1);
|
address(this).call(data1);
|
||||||
address(this).call(data2);
|
address(this).call(data2);
|
||||||
@ -5876,7 +5876,7 @@ BOOST_AUTO_TEST_CASE(external_array_args)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract c {
|
contract c {
|
||||||
function test(uint[8] a, uint[] b, uint[5] c, uint a_index, uint b_index, uint c_index)
|
function test(uint[8] calldata a, uint[] calldata b, uint[5] calldata c, uint a_index, uint b_index, uint c_index)
|
||||||
external returns (uint av, uint bv, uint cv) {
|
external returns (uint av, uint bv, uint cv) {
|
||||||
av = a[a_index];
|
av = a[a_index];
|
||||||
bv = b[b_index];
|
bv = b[b_index];
|
||||||
@ -5901,10 +5901,10 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract c {
|
contract c {
|
||||||
bytes data;
|
bytes data;
|
||||||
function direct(bytes arg, uint index) external returns (uint) {
|
function direct(bytes calldata arg, uint index) external returns (uint) {
|
||||||
return uint(uint8(arg[index]));
|
return uint(uint8(arg[index]));
|
||||||
}
|
}
|
||||||
function storageCopyRead(bytes arg, uint index) external returns (uint) {
|
function storageCopyRead(bytes calldata arg, uint index) external returns (uint) {
|
||||||
data = arg;
|
data = arg;
|
||||||
return uint(uint8(data[index]));
|
return uint(uint8(data[index]));
|
||||||
}
|
}
|
||||||
@ -5959,7 +5959,7 @@ BOOST_AUTO_TEST_CASE(array_copy_calldata_storage)
|
|||||||
uint[9] m_data;
|
uint[9] m_data;
|
||||||
uint[] m_data_dyn;
|
uint[] m_data_dyn;
|
||||||
uint8[][] m_byte_data;
|
uint8[][] m_byte_data;
|
||||||
function store(uint[9] a, uint8[3][] b) external returns (uint8) {
|
function store(uint[9] calldata a, uint8[3][] calldata b) external returns (uint8) {
|
||||||
m_data = a;
|
m_data = a;
|
||||||
m_data_dyn = a;
|
m_data_dyn = a;
|
||||||
m_byte_data = b;
|
m_byte_data = b;
|
||||||
@ -5998,7 +5998,7 @@ BOOST_AUTO_TEST_CASE(array_copy_nested_array)
|
|||||||
uint[4][] a;
|
uint[4][] a;
|
||||||
uint[10][] b;
|
uint[10][] b;
|
||||||
uint[][] c;
|
uint[][] c;
|
||||||
function test(uint[2][] d) external returns (uint) {
|
function test(uint[2][] calldata d) external returns (uint) {
|
||||||
a = d;
|
a = d;
|
||||||
b = a;
|
b = a;
|
||||||
c = b;
|
c = b;
|
||||||
@ -6949,7 +6949,7 @@ BOOST_AUTO_TEST_CASE(return_string)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract Main {
|
contract Main {
|
||||||
string public s;
|
string public s;
|
||||||
function set(string _s) external {
|
function set(string calldata _s) external {
|
||||||
s = _s;
|
s = _s;
|
||||||
}
|
}
|
||||||
function get1() public returns (string memory r) {
|
function get1() public returns (string memory r) {
|
||||||
@ -6975,7 +6975,7 @@ BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes)
|
|||||||
contract Main {
|
contract Main {
|
||||||
string public s1;
|
string public s1;
|
||||||
string public s2;
|
string public s2;
|
||||||
function set(string _s1, uint x, string _s2) external returns (uint) {
|
function set(string calldata _s1, uint x, string calldata _s2) external returns (uint) {
|
||||||
s1 = _s1;
|
s1 = _s1;
|
||||||
s2 = _s2;
|
s2 = _s2;
|
||||||
return x;
|
return x;
|
||||||
@ -7024,7 +7024,7 @@ BOOST_AUTO_TEST_CASE(accessor_involving_strings)
|
|||||||
contract Main {
|
contract Main {
|
||||||
struct stringData { string a; uint b; string c; }
|
struct stringData { string a; uint b; string c; }
|
||||||
mapping(uint => stringData[]) public data;
|
mapping(uint => stringData[]) public data;
|
||||||
function set(uint x, uint y, string a, uint b, string c) external returns (bool) {
|
function set(uint x, uint y, string calldata a, uint b, string calldata c) external returns (bool) {
|
||||||
data[x].length = y + 1;
|
data[x].length = y + 1;
|
||||||
data[x][y].a = a;
|
data[x][y].a = a;
|
||||||
data[x][y].b = b;
|
data[x][y].b = b;
|
||||||
@ -7061,7 +7061,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_function_calls)
|
|||||||
function setIndirectFromMemory(string memory _s1, uint x, string memory _s2) public returns (uint) {
|
function setIndirectFromMemory(string memory _s1, uint x, string memory _s2) public returns (uint) {
|
||||||
return this.set(_s1, x, _s2);
|
return this.set(_s1, x, _s2);
|
||||||
}
|
}
|
||||||
function setIndirectFromCalldata(string _s1, uint x, string _s2) external returns (uint) {
|
function setIndirectFromCalldata(string calldata _s1, uint x, string calldata _s2) external returns (uint) {
|
||||||
return this.set(_s1, x, _s2);
|
return this.set(_s1, x, _s2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7102,7 +7102,7 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal)
|
|||||||
s1 = _s1;
|
s1 = _s1;
|
||||||
_r1 = s1;
|
_r1 = s1;
|
||||||
}
|
}
|
||||||
function set(bytes _s1) external returns (uint _r, bytes memory _r1) {
|
function set(bytes calldata _s1) external returns (uint _r, bytes memory _r1) {
|
||||||
_r1 = doSet(_s1);
|
_r1 = doSet(_s1);
|
||||||
_r = _r1.length;
|
_r = _r1.length;
|
||||||
}
|
}
|
||||||
@ -8040,7 +8040,7 @@ BOOST_AUTO_TEST_CASE(library_call)
|
|||||||
BOOST_AUTO_TEST_CASE(library_function_external)
|
BOOST_AUTO_TEST_CASE(library_function_external)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
library Lib { function m(bytes b) external pure returns (byte) { return b[2]; } }
|
library Lib { function m(bytes calldata b) external pure returns (byte) { return b[2]; } }
|
||||||
contract Test {
|
contract Test {
|
||||||
function f(bytes memory b) public pure returns (byte) {
|
function f(bytes memory b) public pure returns (byte) {
|
||||||
return Lib.m(b);
|
return Lib.m(b);
|
||||||
|
@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(function_external_types)
|
|||||||
uint a;
|
uint a;
|
||||||
}
|
}
|
||||||
contract Test {
|
contract Test {
|
||||||
function boo(uint, bool, bytes8, bool[2], uint[], C, address[]) external returns (uint ret) {
|
function boo(uint, bool, bytes8, bool[2] calldata, uint[] calldata, C, address[] calldata) external returns (uint ret) {
|
||||||
ret = 5;
|
ret = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,10 +206,10 @@ BOOST_AUTO_TEST_CASE(external_structs)
|
|||||||
struct Simple { uint i; }
|
struct Simple { uint i; }
|
||||||
struct Nested { X[2][] a; uint y; }
|
struct Nested { X[2][] a; uint y; }
|
||||||
struct X { bytes32 x; Test t; Simple[] s; }
|
struct X { bytes32 x; Test t; Simple[] s; }
|
||||||
function f(ActionChoices, uint, Simple) external {}
|
function f(ActionChoices, uint, Simple calldata) external {}
|
||||||
function g(Test, Nested) external {}
|
function g(Test, Nested calldata) external {}
|
||||||
function h(function(Nested memory) external returns (uint)[]) external {}
|
function h(function(Nested memory) external returns (uint)[] calldata) external {}
|
||||||
function i(Nested[]) external {}
|
function i(Nested[] calldata) external {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
SourceUnit const* sourceUnit = parseAndAnalyse(text);
|
SourceUnit const* sourceUnit = parseAndAnalyse(text);
|
||||||
@ -234,10 +234,10 @@ BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
|
|||||||
struct Simple { uint i; }
|
struct Simple { uint i; }
|
||||||
struct Nested { X[2][] a; uint y; }
|
struct Nested { X[2][] a; uint y; }
|
||||||
struct X { bytes32 x; Test t; Simple[] s; }
|
struct X { bytes32 x; Test t; Simple[] s; }
|
||||||
function f(ActionChoices, uint, Simple) external {}
|
function f(ActionChoices, uint, Simple calldata) external {}
|
||||||
function g(Test, Nested) external {}
|
function g(Test, Nested calldata) external {}
|
||||||
function h(function(Nested memory) external returns (uint)[]) external {}
|
function h(function(Nested memory) external returns (uint)[] calldata) external {}
|
||||||
function i(Nested[]) external {}
|
function i(Nested[] calldata) external {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
SourceUnit const* sourceUnit = parseAndAnalyse(text);
|
SourceUnit const* sourceUnit = parseAndAnalyse(text);
|
||||||
@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(string)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
string s;
|
string s;
|
||||||
function f(string x) external { s = x; }
|
function f(string calldata x) external { s = x; }
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
|
BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
contract test {
|
contract test {
|
||||||
function f() public pure returns (bytes) {
|
function f() public pure returns (bytes memory) {
|
||||||
return bytes("abc");
|
return bytes("abc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user