diff options
author | winsvega <winsvega@mail.ru> | 2015-02-10 18:19:27 +0800 |
---|---|---|
committer | winsvega <winsvega@mail.ru> | 2015-02-10 18:19:27 +0800 |
commit | 30db15c1a9933972f0ad0236e50bc967ebf24dd3 (patch) | |
tree | 3ca08f951f2dee908dce70271c984d32c30d0adc /SolidityParser.cpp | |
parent | c09b7885e88b842a024e6b8a2e6cf5fd5d845ab3 (diff) | |
parent | 8f9511c6ec3a7df05188e9aa6322b5ec0932c095 (diff) | |
download | dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar.gz dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar.bz2 dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar.lz dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar.xz dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.tar.zst dexon-solidity-30db15c1a9933972f0ad0236e50bc967ebf24dd3.zip |
Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into develop
Diffstat (limited to 'SolidityParser.cpp')
-rw-r--r-- | SolidityParser.cpp | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/SolidityParser.cpp b/SolidityParser.cpp index 4adee9c6..7af99567 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -124,14 +124,30 @@ BOOST_AUTO_TEST_CASE(single_function_param) BOOST_CHECK_NO_THROW(parseText(text)); } +BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args) +{ + char const* text = "contract test {\n" + " function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" + " function b() returns (uint r) { r = a({: 1, : 2, : 3}); }\n" + "}\n"; + BOOST_CHECK_THROW(parseText(text), ParserError); +} + +BOOST_AUTO_TEST_CASE(missing_argument_in_named_args) +{ + char const* text = "contract test {\n" + " function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n" + " function b() returns (uint r) { r = a({a: , b: , c: }); }\n" + "}\n"; + BOOST_CHECK_THROW(parseText(text), ParserError); +} + BOOST_AUTO_TEST_CASE(function_natspec_documentation) { ASTPointer<ContractDefinition> contract; ASTPointer<FunctionDefinition> function; char const* text = "contract test {\n" - " private:\n" - " uint256 stateVar;\n" - " public:\n" + " uint256 stateVar;\n" " /// This is a test function\n" " function functionName(hash hashin) returns (hash hashout) {}\n" "}\n"; @@ -162,9 +178,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) ASTPointer<ContractDefinition> contract; ASTPointer<FunctionDefinition> function; char const* text = "contract test {\n" - " private:\n" " uint256 stateVar;\n" - " public:\n" " /// This is test function 1\n" " function functionName1(hash hashin) returns (hash hashout) {}\n" " /// This is test function 2\n" @@ -621,6 +635,63 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed) BOOST_CHECK_NO_THROW(parseText(text)); } +BOOST_AUTO_TEST_CASE(visibility_specifiers) +{ + char const* text = R"( + contract c { + uint private a; + uint protected b; + uint public c; + uint d; + function f() {} + function f_priv() private {} + function f_public() public {} + function f_protected() protected {} + })"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + +BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) +{ + char const* text = R"( + contract c { + uint private protected a; + })"; + BOOST_CHECK_THROW(parseText(text), ParserError); +} + +BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) +{ + char const* text = R"( + contract c { + function c () + { + a = 1 wei; + b = 2 szabo; + c = 3 finney; + b = 4 ether; + } + uint256 a; + uint256 b; + uint256 c; + uint256 d; + })"; + BOOST_CHECK_NO_THROW(parseTextExplainError(text)); +} + +BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions) +{ + char const* text = R"( + contract c { + function c () + { + a = 1 wei * 100 wei + 7 szabo - 3; + } + uint256 a; + })"; + BOOST_CHECK_NO_THROW(parseTextExplainError(text)); +} + BOOST_AUTO_TEST_SUITE_END() } |