Fix: Allow multiple @return tags on public state variables

This commit is contained in:
Mathias Baumann
2021-06-07 15:16:46 +02:00
parent aae9d347aa
commit 354f9d1015
4 changed files with 97 additions and 27 deletions
+67
View File
@@ -328,6 +328,73 @@ BOOST_AUTO_TEST_CASE(public_state_variable)
checkNatspec(sourceCode, "test", userDoc, true);
}
BOOST_AUTO_TEST_CASE(public_state_variable_struct)
{
char const* sourceCode = R"(
contract Bank {
struct Coin {
string observeGraphicURL;
string reverseGraphicURL;
}
/// @notice Get the n-th coin I own
/// @return observeGraphicURL Front pic
/// @return reverseGraphicURL Back pic
Coin[] public coinStack;
}
)";
char const* devDoc = R"R(
{
"methods" : {},
"stateVariables" :
{
"coinStack" :
{
"returns" :
{
"observeGraphicURL" : "Front pic",
"reverseGraphicURL" : "Back pic"
}
}
}
}
)R";
checkNatspec(sourceCode, "Bank", devDoc, false);
char const* userDoc = R"R(
{
"methods" :
{
"coinStack(uint256)" :
{
"notice": "Get the n-th coin I own"
}
}
}
)R";
checkNatspec(sourceCode, "Bank", userDoc, true);
}
BOOST_AUTO_TEST_CASE(public_state_variable_struct_repeated)
{
char const* sourceCode = R"(
contract Bank {
struct Coin {
string obverseGraphicURL;
string reverseGraphicURL;
}
/// @notice Get the n-th coin I own
/// @return obverseGraphicURL Front pic
/// @return obverseGraphicURL Front pic
Coin[] public coinStack;
}
)";
expectNatspecError(sourceCode);
}
BOOST_AUTO_TEST_CASE(private_state_variable)
{
char const* sourceCode = R"(
@@ -6,4 +6,4 @@ contract test {
uint public state;
}
// ----
// DocstringParsingError 5256: (18-137): Documentation tag "@return" is only allowed once on state-variables.
// DocstringParsingError 2604: (18-137): Documentation tag "@return returns something" exceeds the number of return parameters.