diff options
author | chriseth <c@ethdev.com> | 2015-11-27 00:40:40 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-11-27 00:40:40 +0800 |
commit | c806b9bcdb26fe031da94b8cdb270cb3c75b8af9 (patch) | |
tree | 83159d4b3367d9278ea67d37409fa856c58f11bb /test/libsolidity | |
parent | c498dcce22b2921ee57f280da9117e491c021e1b (diff) | |
parent | 4aaa150674d5970f651ab3e95e5b0e2daac0e7e0 (diff) | |
download | dexon-solidity-c806b9bcdb26fe031da94b8cdb270cb3c75b8af9.tar.gz dexon-solidity-c806b9bcdb26fe031da94b8cdb270cb3c75b8af9.tar.zst dexon-solidity-c806b9bcdb26fe031da94b8cdb270cb3c75b8af9.zip |
Merge pull request #246 from chriseth/refactor
Refactoring - more flexible contracts.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index beb71942..7451397e 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -73,7 +73,7 @@ bool successParse(std::string const& _source) } void checkFunctionNatspec( - ASTPointer<FunctionDefinition> _function, + FunctionDefinition const* _function, std::string const& _expectedDoc ) { @@ -191,20 +191,18 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) " function functionName(bytes32 input) returns (bytes32 out) {}\n" "}\n"; BOOST_CHECK(successParse(text)); - ErrorList e; - ASTPointer<ContractDefinition> contract = parseText(text, e); - ASTPointer<FunctionDefinition> function; - ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + FunctionDefinition const* function = nullptr; + auto functions = contract->definedFunctions(); + ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); checkFunctionNatspec(function, "This is a test function"); } BOOST_AUTO_TEST_CASE(function_normal_comments) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " // We won't see this comment\n" @@ -212,7 +210,8 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); BOOST_CHECK_MESSAGE(function->documentation() == nullptr, "Should not have gotten a Natspecc comment for this function"); @@ -220,8 +219,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is test function 1\n" @@ -235,7 +233,8 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); checkFunctionNatspec(function, "This is test function 1"); @@ -253,8 +252,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) BOOST_AUTO_TEST_CASE(multiline_function_documentation) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is a test function\n" @@ -263,7 +261,8 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); checkFunctionNatspec(function, "This is a test function\n" " and it has 2 lines"); @@ -271,8 +270,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " /// fun1 description\n" " function fun1(uint256 a) {\n" @@ -288,7 +286,8 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); checkFunctionNatspec(function, "fun1 description"); @@ -300,8 +299,7 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " function ///I am in the wrong place \n" @@ -315,7 +313,8 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); BOOST_CHECK_MESSAGE(!function->documentation(), @@ -324,8 +323,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) { - ASTPointer<ContractDefinition> contract; - ASTPointer<FunctionDefinition> function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " function fun1(uint256 a) {\n" @@ -339,7 +337,8 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) "}\n"; BOOST_CHECK(successParse(text)); ErrorList errors; - auto functions = parseText(text, errors)->definedFunctions(); + ASTPointer<ContractDefinition> contract = parseText(text, errors); + auto functions = contract->definedFunctions(); ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); BOOST_CHECK_MESSAGE(!function->documentation(), |