diff options
author | chriseth <c@ethdev.com> | 2015-06-29 18:47:04 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-29 18:47:04 +0800 |
commit | e1b2a79b8b64199b98ec41377da6202f9c26dfcb (patch) | |
tree | c522aecad9c955fdafe0dd6a3a29b5643553a81c | |
parent | 7100b14d4dcf3f952f53cd20c58b8ece4a53580c (diff) | |
download | dexon-solidity-e1b2a79b8b64199b98ec41377da6202f9c26dfcb.tar.gz dexon-solidity-e1b2a79b8b64199b98ec41377da6202f9c26dfcb.tar.zst dexon-solidity-e1b2a79b8b64199b98ec41377da6202f9c26dfcb.zip |
Another test for arrays in constructors.
-rw-r--r-- | libsolidity/SolidityEndToEndTest.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 9451c8cf..a2dbc35e 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4493,7 +4493,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) } } contract Main is Base { - function Main(bytes s, uint x) Base(x, s){}//f(s)) {} + function Main(bytes s, uint x) Base(x, f(s)) {} function f(bytes s) returns (bytes) { return s; } @@ -4517,6 +4517,45 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) ); } +BOOST_AUTO_TEST_CASE(arrays_in_constructors) +{ + char const* sourceCode = R"( + contract Base { + uint public m_x; + address[] m_s; + function Base(uint x, address[] s) { + m_x = x; + m_s = s; + } + function part(uint i) returns (address) { + return m_s[i]; + } + } + contract Main is Base { + function Main(address[] s, uint x) Base(x, f(s)) {} + function f(address[] s) returns (address[]) { + return s; + } + } + contract Creator { + function f(uint x, address[] s) returns (uint r, address ch) { + var c = new Main(s, x); + r = c.m_x(); + ch = c.part(x); + } + } + )"; + compileAndRun(sourceCode, 0, "Creator"); + vector<u256> s1{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + bytes dyn1 = encodeArgs(u256(s1.size()), s1); + u256 x = 7; + bytes args1 = encodeArgs(x, u256(0x40)) + dyn1; + BOOST_REQUIRE( + callContractFunction("f(uint256,address[])", asString(args1)) == + encodeArgs(x, s1[unsigned(x)]) + ); +} + BOOST_AUTO_TEST_CASE(arrays_from_and_to_storage) { char const* sourceCode = R"( |