Multi-variable declarations.

This commit is contained in:
chriseth
2015-10-13 12:16:23 +02:00
parent a5d12b8761
commit deebc7e860
9 changed files with 166 additions and 77 deletions
@@ -2405,6 +2405,65 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail)
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine)
{
char const* text = R"(
contract C {
function three() returns (uint, uint, uint);
function two() returns (uint, uint);
function f() {
var (a,) = three();
var (b,c,) = two();
var (,d) = three();
var (,e,g) = two();
}
)";
BOOST_CHECK_NO_THROW(parseAndAnalyseReturnError(text));
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1)
{
char const* text = R"(
contract C {
function one() returns (uint);
function f() { var (a, b, ) = one(); }
}
)";
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2)
{
char const* text = R"(
contract C {
function one() returns (uint);
function f() { var (a, , ) = one(); }
}
)";
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3)
{
char const* text = R"(
contract C {
function one() returns (uint);
function f() { var (, , a) = one(); }
}
)";
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4)
{
char const* text = R"(
contract C {
function one() returns (uint);
function f() { var (, a, b) = one(); }
}
)";
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
BOOST_AUTO_TEST_SUITE_END()
}
-12
View File
@@ -952,18 +952,6 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration)
BOOST_CHECK_NO_THROW(parseText(text));
}
BOOST_AUTO_TEST_CASE(multi_variable_declaration_invalid)
{
char const* text = R"(
library Lib {
function f() {
var () = g();
}
}
)";
BOOST_CHECK_THROW(parseText(text), ParserError);
}
BOOST_AUTO_TEST_SUITE_END()
}