diff options
author | chriseth <c@ethdev.com> | 2015-11-24 07:20:37 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-11-26 22:37:55 +0800 |
commit | 2e4f4e3363586f3557bd36547d05a303d287015b (patch) | |
tree | 35d96cb7c45c6664c7555ac439b50c71b11a2c24 /test/libsolidity | |
parent | b47d5932528357939ee29758a8b8027c90bdb1e5 (diff) | |
download | dexon-solidity-2e4f4e3363586f3557bd36547d05a303d287015b.tar.gz dexon-solidity-2e4f4e3363586f3557bd36547d05a303d287015b.tar.zst dexon-solidity-2e4f4e3363586f3557bd36547d05a303d287015b.zip |
Fix smart pointer lifetime issue in tests.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index b494a1aa..7451397e 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -191,19 +191,17 @@ 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); + ErrorList errors; + ASTPointer<ContractDefinition> contract = parseText(text, errors); FunctionDefinition const* function = nullptr; + auto functions = contract->definedFunctions(); - ErrorList errors; - auto functions = parseText(text, errors)->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; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\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,7 +219,6 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) { - ASTPointer<ContractDefinition> contract; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\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,7 +252,6 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) BOOST_AUTO_TEST_CASE(multiline_function_documentation) { - ASTPointer<ContractDefinition> contract; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\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,7 +270,6 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) { - ASTPointer<ContractDefinition> contract; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " /// fun1 description\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,7 +299,6 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) { - ASTPointer<ContractDefinition> contract; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\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,7 +323,6 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) { - ASTPointer<ContractDefinition> contract; FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\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(), |