mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Separate user and dev natspec documentation
- plus other small changes according to the spec
This commit is contained in:
parent
92724ab80a
commit
2f7b263f9b
@ -35,8 +35,11 @@ namespace test
|
|||||||
class DocumentationChecker
|
class DocumentationChecker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void checkNatspec(std::string const& _code, std::string const& _expectedDocumentationString)
|
void checkNatspec(std::string const& _code,
|
||||||
|
std::string const& _expectedDocumentationString,
|
||||||
|
bool _userDocumentation)
|
||||||
{
|
{
|
||||||
|
std::string generatedDocumentationString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_compilerStack.parse(_code);
|
m_compilerStack.parse(_code);
|
||||||
@ -50,7 +53,11 @@ public:
|
|||||||
msg += *extra;
|
msg += *extra;
|
||||||
BOOST_FAIL(msg);
|
BOOST_FAIL(msg);
|
||||||
}
|
}
|
||||||
auto generatedDocumentationString = m_compilerStack.getDocumentation();
|
|
||||||
|
if (_userDocumentation)
|
||||||
|
generatedDocumentationString = m_compilerStack.getUserDocumentation();
|
||||||
|
else
|
||||||
|
generatedDocumentationString = m_compilerStack.getDevDocumentation();
|
||||||
Json::Value generatedDocumentation;
|
Json::Value generatedDocumentation;
|
||||||
m_reader.parse(generatedDocumentationString, generatedDocumentation);
|
m_reader.parse(generatedDocumentationString, generatedDocumentation);
|
||||||
Json::Value expectedDocumentation;
|
Json::Value expectedDocumentation;
|
||||||
@ -67,7 +74,7 @@ private:
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(SolidityNatspecJSON, DocumentationChecker)
|
BOOST_FIXTURE_TEST_SUITE(SolidityNatspecJSON, DocumentationChecker)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(basic_test)
|
BOOST_AUTO_TEST_CASE(user_basic_test)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
" /// Multiplies `a` by 7\n"
|
" /// Multiplies `a` by 7\n"
|
||||||
@ -76,13 +83,13 @@ BOOST_AUTO_TEST_CASE(basic_test)
|
|||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
" \"mul\":{ \"user\": \" Multiplies `a` by 7\"}"
|
" \"mul\":{ \"notice\": \" Multiplies `a` by 7\"}"
|
||||||
"}}";
|
"}}";
|
||||||
|
|
||||||
checkNatspec(sourceCode, natspec);
|
checkNatspec(sourceCode, natspec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiline_comment)
|
BOOST_AUTO_TEST_CASE(user_multiline_comment)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
" /// Multiplies `a` by 7\n"
|
" /// Multiplies `a` by 7\n"
|
||||||
@ -95,13 +102,13 @@ BOOST_AUTO_TEST_CASE(multiline_comment)
|
|||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
" \"mul_and_add\":{ \"user\": \" Multiplies `a` by 7\n and then adds `b`\"}"
|
" \"mul_and_add\":{ \"notice\": \" Multiplies `a` by 7\n and then adds `b`\"}"
|
||||||
"}}";
|
"}}";
|
||||||
|
|
||||||
checkNatspec(sourceCode, natspec);
|
checkNatspec(sourceCode, natspec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_functions)
|
BOOST_AUTO_TEST_CASE(user_multiple_functions)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
" /// Multiplies `a` by 7\n"
|
" /// Multiplies `a` by 7\n"
|
||||||
@ -125,22 +132,22 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
|
|||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
" \"mul_and_add\":{ \"user\": \" Multiplies `a` by 7\n and then adds `b`\"},"
|
" \"mul_and_add\":{ \"notice\": \" Multiplies `a` by 7\n and then adds `b`\"},"
|
||||||
" \"divide\":{ \"user\": \" Divides `input` by `div`\"},"
|
" \"divide\":{ \"notice\": \" Divides `input` by `div`\"},"
|
||||||
" \"sub\":{ \"user\": \" Subtracts 3 from `input`\"}"
|
" \"sub\":{ \"notice\": \" Subtracts 3 from `input`\"}"
|
||||||
"}}";
|
"}}";
|
||||||
|
|
||||||
checkNatspec(sourceCode, natspec);
|
checkNatspec(sourceCode, natspec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(empty_contract)
|
BOOST_AUTO_TEST_CASE(user_empty_contract)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
char const* natspec = "{\"methods\":{} }";
|
char const* natspec = "{\"methods\":{} }";
|
||||||
|
|
||||||
checkNatspec(sourceCode, natspec);
|
checkNatspec(sourceCode, natspec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user