mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Solidity function AST nodes get documentation attribute
This commit is contained in:
parent
0cd1e76553
commit
ce7bbca1e5
@ -37,13 +37,14 @@ namespace test
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
ASTPointer<ASTNode> parseText(std::string const& _source)
|
ASTPointer<ContractDefinition> parseText(std::string const& _source)
|
||||||
{
|
{
|
||||||
Parser parser;
|
Parser parser;
|
||||||
return parser.parse(std::make_shared<Scanner>(CharStream(_source)));
|
return parser.parse(std::make_shared<Scanner>(CharStream(_source)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SolidityParser)
|
BOOST_AUTO_TEST_SUITE(SolidityParser)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(smoke_test)
|
BOOST_AUTO_TEST_CASE(smoke_test)
|
||||||
@ -91,6 +92,36 @@ BOOST_AUTO_TEST_CASE(single_function_param)
|
|||||||
BOOST_CHECK_NO_THROW(parseText(text));
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
|
||||||
|
{
|
||||||
|
ASTPointer<ContractDefinition> contract;
|
||||||
|
ASTPointer<FunctionDefinition> function;
|
||||||
|
char const* text = "contract test {\n"
|
||||||
|
" uint256 stateVar;\n"
|
||||||
|
" /// This is a test function\n"
|
||||||
|
" function functionName(hash hashin) returns (hash hashout) {}\n"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_NO_THROW(contract = parseText(text));
|
||||||
|
auto functions = contract->getDefinedFunctions();
|
||||||
|
BOOST_CHECK_NO_THROW(function = functions.at(0));
|
||||||
|
BOOST_CHECK_EQUAL(function->getDocumentation(), " This is a test function");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(function_normal_comments)
|
||||||
|
{
|
||||||
|
ASTPointer<ContractDefinition> contract;
|
||||||
|
ASTPointer<FunctionDefinition> function;
|
||||||
|
char const* text = "contract test {\n"
|
||||||
|
" uint256 stateVar;\n"
|
||||||
|
" // We won't see this comment\n"
|
||||||
|
" function functionName(hash hashin) returns (hash hashout) {}\n"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_NO_THROW(contract = parseText(text));
|
||||||
|
auto functions = contract->getDefinedFunctions();
|
||||||
|
BOOST_CHECK_NO_THROW(function = functions.at(0));
|
||||||
|
BOOST_CHECK_EQUAL(function->getDocumentation(), "");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(struct_definition)
|
BOOST_AUTO_TEST_CASE(struct_definition)
|
||||||
{
|
{
|
||||||
char const* text = "contract test {\n"
|
char const* text = "contract test {\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user