diff options
author | chriseth <c@ethdev.com> | 2015-10-10 02:44:56 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-13 18:16:23 +0800 |
commit | deebc7e8601185006b74a5ee78b83c50bdf37abc (patch) | |
tree | fcd4f68acc0ca65e10e16eba170bc89180ea9468 /test | |
parent | a5d12b876180088904a026c472da23201a35d59c (diff) | |
download | dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.gz dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.zst dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.zip |
Multi-variable declarations.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 59 | ||||
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 12 |
2 files changed, 59 insertions, 12 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index fc6d54a8..4316c6a8 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -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() } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 0e69bfa8..569530b9 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -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() } |