diff options
author | wadeAlexC <wade.alex.c@gmail.com> | 2017-09-22 05:42:34 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-25 17:42:01 +0800 |
commit | 0099911ace631789ab8a2294710b9fd57af1c478 (patch) | |
tree | 43863cdf1d56406ef3135689b27c109e7f590152 /test/libsolidity | |
parent | ccb689701e6a602a44bf2941ca71c683f96907d1 (diff) | |
download | dexon-solidity-0099911ace631789ab8a2294710b9fd57af1c478.tar.gz dexon-solidity-0099911ace631789ab8a2294710b9fd57af1c478.tar.zst dexon-solidity-0099911ace631789ab8a2294710b9fd57af1c478.zip |
Better error message for unexpected trailing comma in parameter lists
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index a8698d13..72473c3e 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -167,6 +167,90 @@ BOOST_AUTO_TEST_CASE(single_function_param) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(single_function_param_trailing_comma) +{ + char const* text = R"( + contract test { + function(uint a,) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(single_return_param_trailing_comma) +{ + char const* text = R"( + contract test { + function() returns (uint a,) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(single_modifier_arg_trailing_comma) +{ + char const* text = R"( + contract test { + modifier modTest(uint a,) { _; } + function(uint a) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(single_event_arg_trailing_comma) +{ + char const* text = R"( + contract test { + event Test(uint a,); + function(uint a) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(multiple_function_param_trailing_comma) +{ + char const* text = R"( + contract test { + function(uint a, uint b,) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(multiple_return_param_trailing_comma) +{ + char const* text = R"( + contract test { + function() returns (uint a, uint b,) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(multiple_modifier_arg_trailing_comma) +{ + char const* text = R"( + contract test { + modifier modTest(uint a, uint b,) { _; } + function(uint a) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + +BOOST_AUTO_TEST_CASE(multiple_event_arg_trailing_comma) +{ + char const* text = R"( + contract test { + event Test(uint a, uint b,); + function(uint a) {} + } + )"; + CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list."); +} + BOOST_AUTO_TEST_CASE(function_no_body) { char const* text = R"( |