From b47d5932528357939ee29758a8b8027c90bdb1e5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 23 Nov 2015 23:57:17 +0100 Subject: Do not store elements of a contract by AST node type. --- test/libsolidity/SolidityParser.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index beb71942..b494a1aa 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -73,7 +73,7 @@ bool successParse(std::string const& _source) } void checkFunctionNatspec( - ASTPointer _function, + FunctionDefinition const* _function, std::string const& _expectedDoc ) { @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) BOOST_CHECK(successParse(text)); ErrorList e; ASTPointer contract = parseText(text, e); - ASTPointer function; + FunctionDefinition const* function = nullptr; ErrorList errors; auto functions = parseText(text, errors)->definedFunctions(); @@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) BOOST_AUTO_TEST_CASE(function_normal_comments) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " // We won't see this comment\n" @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is test function 1\n" @@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) BOOST_AUTO_TEST_CASE(multiline_function_documentation) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is a test function\n" @@ -272,7 +272,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " /// fun1 description\n" " function fun1(uint256 a) {\n" @@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " function ///I am in the wrong place \n" @@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) { ASTPointer contract; - ASTPointer function; + FunctionDefinition const* function = nullptr; char const* text = "contract test {\n" " uint256 stateVar;\n" " function fun1(uint256 a) {\n" -- cgit v1.2.3 From 2e4f4e3363586f3557bd36547d05a303d287015b Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 24 Nov 2015 00:20:37 +0100 Subject: Fix smart pointer lifetime issue in tests. --- test/libsolidity/SolidityParser.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'test') 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 contract = parseText(text, e); + ErrorList errors; + ASTPointer 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 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 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 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 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 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 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 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 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 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 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 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 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(), -- cgit v1.2.3