diff options
author | chriseth <chris@ethereum.org> | 2017-08-25 02:50:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 02:50:37 +0800 |
commit | d7661dd97460250b4e1127b9e7ea91e116143780 (patch) | |
tree | 0d909e7aeec373b0559b9d80f8ae9a9e03bdd92b /test/libsolidity/SolidityParser.cpp | |
parent | bbb8e64fbee632d1594f6c132b1174591b961207 (diff) | |
parent | dd67e5966f41be0b2ef52041ea726930af74f7e9 (diff) | |
download | dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.gz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.bz2 dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.lz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.xz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.zst dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.zip |
Merge pull request #2802 from ethereum/develop
Merge develop into release for 0.4.16
Diffstat (limited to 'test/libsolidity/SolidityParser.cpp')
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 87 |
1 files changed, 78 insertions, 9 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 78edd4d1..a39e0958 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -898,25 +898,46 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) contract c { uint private internal a; })"; - CHECK_PARSE_ERROR(text, "Visibility already specified"); + CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\"."); + text = R"( + contract c { + function f() private external {} + })"; + CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\"."); } -BOOST_AUTO_TEST_CASE(multiple_payable_specifiers) +BOOST_AUTO_TEST_CASE(multiple_statemutability_specifiers) { char const* text = R"( contract c { function f() payable payable {} })"; - CHECK_PARSE_ERROR(text, "Multiple \"payable\" specifiers."); -} - -BOOST_AUTO_TEST_CASE(multiple_constant_specifiers) -{ - char const* text = R"( + CHECK_PARSE_ERROR(text, "State mutability already specified as \"payable\"."); + text = R"( contract c { function f() constant constant {} })"; - CHECK_PARSE_ERROR(text, "Multiple \"constant\" specifiers."); + CHECK_PARSE_ERROR(text, "State mutability already specified as \"view\"."); + text = R"( + contract c { + function f() constant view {} + })"; + CHECK_PARSE_ERROR(text, "State mutability already specified as \"view\"."); + text = R"( + contract c { + function f() payable constant {} + })"; + CHECK_PARSE_ERROR(text, "State mutability already specified as \"payable\"."); + text = R"( + contract c { + function f() pure payable {} + })"; + CHECK_PARSE_ERROR(text, "State mutability already specified as \"pure\"."); + text = R"( + contract c { + function f() pure constant {} + })"; + CHECK_PARSE_ERROR(text, "State mutability already specified as \"pure\"."); } BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) @@ -1182,6 +1203,18 @@ BOOST_AUTO_TEST_CASE(tuples) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(tuples_without_commas) +{ + char const* text = R"( + contract C { + function f() { + var a = (2 2); + } + } + )"; + CHECK_PARSE_ERROR(text, "Expected token Comma"); +} + BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity) { char const* text = R"( @@ -1345,6 +1378,42 @@ BOOST_AUTO_TEST_CASE(conditional_with_assignment) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(recursion_depth1) +{ + string text("contract C { bytes"); + for (size_t i = 0; i < 30000; i++) + text += "["; + CHECK_PARSE_ERROR(text.c_str(), "Maximum recursion depth reached during parsing"); +} + +BOOST_AUTO_TEST_CASE(recursion_depth2) +{ + string text("contract C { function f() {"); + for (size_t i = 0; i < 30000; i++) + text += "{"; + CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing"); +} + +BOOST_AUTO_TEST_CASE(recursion_depth3) +{ + string text("contract C { function f() { uint x = f("); + for (size_t i = 0; i < 30000; i++) + text += "("; + CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing"); +} + +BOOST_AUTO_TEST_CASE(recursion_depth4) +{ + string text("contract C { function f() { uint a;"); + for (size_t i = 0; i < 30000; i++) + text += "("; + text += "a"; + for (size_t i = 0; i < 30000; i++) + text += "++)"; + text += "}}"; + CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing"); +} + BOOST_AUTO_TEST_CASE(declaring_fixed_and_ufixed_variables) { char const* text = R"( |