mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Natspec title and author tag.
- Adding the title and author natspec documentation tags for contracts - Also using the author tag for functions now - Tests
This commit is contained in:
parent
8aba43c5e0
commit
7724cf1f58
@ -22,6 +22,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <libsolidity/CompilerStack.h>
|
||||
#include <libsolidity/Exceptions.h>
|
||||
#include <jsonrpc/json/json.h>
|
||||
#include <libdevcore/Exceptions.h>
|
||||
|
||||
@ -393,6 +394,93 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
|
||||
checkNatspec(sourceCode, natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
|
||||
{
|
||||
char const* sourceCode = "contract test {\n"
|
||||
" /// @dev Mul function\n"
|
||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
||||
"}\n";
|
||||
|
||||
char const* natspec = "{"
|
||||
" \"methods\":{"
|
||||
" \"mul\":{ \n"
|
||||
" \"details\": \"Mul function\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}";
|
||||
|
||||
checkNatspec(sourceCode, natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_contract_doc)
|
||||
{
|
||||
char const* sourceCode = " /// @author Lefteris\n"
|
||||
" /// @title Just a test contract\n"
|
||||
"contract test {\n"
|
||||
" /// @dev Mul function\n"
|
||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
||||
"}\n";
|
||||
|
||||
char const* natspec = "{"
|
||||
" \"author\": \"Lefteris\","
|
||||
" \"title\": \"Just a test contract\","
|
||||
" \"methods\":{"
|
||||
" \"mul\":{ \n"
|
||||
" \"details\": \"Mul function\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}";
|
||||
|
||||
checkNatspec(sourceCode, natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_author_at_function)
|
||||
{
|
||||
char const* sourceCode = " /// @author Lefteris\n"
|
||||
" /// @title Just a test contract\n"
|
||||
"contract test {\n"
|
||||
" /// @dev Mul function\n"
|
||||
" /// @author John Doe\n"
|
||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
||||
"}\n";
|
||||
|
||||
char const* natspec = "{"
|
||||
" \"author\": \"Lefteris\","
|
||||
" \"title\": \"Just a test contract\","
|
||||
" \"methods\":{"
|
||||
" \"mul\":{ \n"
|
||||
" \"details\": \"Mul function\",\n"
|
||||
" \"author\": \"John Doe\",\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}";
|
||||
|
||||
checkNatspec(sourceCode, natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
|
||||
{
|
||||
char const* sourceCode = " /// @author Lefteris\n"
|
||||
" /// @title Just a test contract\n"
|
||||
"contract test {\n"
|
||||
" /// @dev Mul function\n"
|
||||
" /// @title I really should not be here\n"
|
||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
||||
"}\n";
|
||||
|
||||
char const* natspec = "{"
|
||||
" \"author\": \"Lefteris\","
|
||||
" \"title\": \"Just a test contract\","
|
||||
" \"methods\":{"
|
||||
" \"mul\":{ \n"
|
||||
" \"details\": \"Mul function\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}";
|
||||
|
||||
BOOST_CHECK_THROW(checkNatspec(sourceCode, natspec, false), DocstringParsingError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user