mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests for multi variable declaration statement.
This commit is contained in:
committed by
Alex Beregszaszi
parent
67d208d144
commit
c781baf733
@@ -7610,6 +7610,33 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration)
|
||||
ABI_CHECK(callContractFunction("f()", encodeArgs()), encodeArgs(true));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(typed_multi_variable_declaration)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
struct S { uint x; }
|
||||
S s;
|
||||
function g() internal returns (uint, S storage, uint) {
|
||||
s.x = 7;
|
||||
return (1, s, 2);
|
||||
}
|
||||
function f() returns (bool) {
|
||||
(uint x1, S storage y1, uint z1) = g();
|
||||
if (x1 != 1 || y1.x != 7 || z1 != 2) return false;
|
||||
(, S storage y2,) = g();
|
||||
if (y2.x != 7) return false;
|
||||
(uint x2,,) = g();
|
||||
if (x2 != 1) return false;
|
||||
(,,uint z2) = g();
|
||||
if (z2 != 2) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("f()", encodeArgs()), encodeArgs(true));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(tuples)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
||||
Reference in New Issue
Block a user