mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement @erak review notes by creating function and adding constructor test
Update 060 doc with natspec change Add two more tests with mixed usage Fix solc-js fix changelog
This commit is contained in:
@@ -44,13 +44,13 @@ abstract contract TokenInterface {
|
||||
uint256 public totalSupply;
|
||||
|
||||
/// @param _owner The address from which the balance will be retrieved
|
||||
/// @return The balance
|
||||
/// @return balance The balance
|
||||
function balanceOf(address _owner) public view returns (uint256 balance);
|
||||
|
||||
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
|
||||
/// @param _to The address of the recipient
|
||||
/// @param _amount The amount of tokens to be transferred
|
||||
/// @return Whether the transfer was successful or not
|
||||
/// @return success Whether the transfer was successful or not
|
||||
function transfer(address _to, uint256 _amount) public returns (bool success);
|
||||
|
||||
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
|
||||
@@ -58,19 +58,19 @@ abstract contract TokenInterface {
|
||||
/// @param _from The address of the origin of the transfer
|
||||
/// @param _to The address of the recipient
|
||||
/// @param _amount The amount of tokens to be transferred
|
||||
/// @return Whether the transfer was successful or not
|
||||
/// @return success Whether the transfer was successful or not
|
||||
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success);
|
||||
|
||||
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
|
||||
/// its behalf
|
||||
/// @param _spender The address of the account able to transfer the tokens
|
||||
/// @param _amount The amount of tokens to be approved for transfer
|
||||
/// @return Whether the approval was successful or not
|
||||
/// @return success Whether the approval was successful or not
|
||||
function approve(address _spender, uint256 _amount) public returns (bool success);
|
||||
|
||||
/// @param _owner The address of the account owning tokens
|
||||
/// @param _spender The address of the account able to transfer the tokens
|
||||
/// @return Amount of remaining tokens of _owner that _spender is allowed
|
||||
/// @return remaining Amount of remaining tokens of _owner that _spender is allowed
|
||||
/// to spend
|
||||
function allowance(
|
||||
address _owner,
|
||||
|
||||
@@ -378,7 +378,7 @@ BOOST_AUTO_TEST_CASE(dev_return)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"returns\": {\n"
|
||||
" \"d\": \"The result of the multiplication\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
@@ -411,7 +411,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"returns\": {\n"
|
||||
" \"d\": \"The result of the multiplication\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
@@ -420,6 +420,79 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
|
||||
checkNatspec(sourceCode, "test", natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_return_desc_multiple_unamed_mixed)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
/// @dev Multiplies a number by 7 and adds second parameter
|
||||
/// @param a Documentation for the first parameter starts here.
|
||||
/// Since it's a really complicated parameter we need 2 lines
|
||||
/// @param second Documentation for the second parameter
|
||||
/// @return The result of the multiplication
|
||||
/// @return _cookies And cookies with nutella
|
||||
function mul(uint a, uint second) public returns (uint, uint _cookies) {
|
||||
uint mul = a * 7;
|
||||
return (mul, second);
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
char const* natspec = "{"
|
||||
"\"methods\":{"
|
||||
" \"mul(uint256,uint256)\":{ \n"
|
||||
" \"details\": \"Multiplies a number by 7 and adds second parameter\",\n"
|
||||
" \"params\": {\n"
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"returns\": {\n"
|
||||
" \"_0\": \"The result of the multiplication\",\n"
|
||||
" \"_cookies\": \"And cookies with nutella\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}}";
|
||||
|
||||
checkNatspec(sourceCode, "test", natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_return_desc_multiple_unamed_mixed_2)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
/// @dev Multiplies a number by 7 and adds second parameter
|
||||
/// @param a Documentation for the first parameter starts here.
|
||||
/// Since it's a really complicated parameter we need 2 lines
|
||||
/// @param second Documentation for the second parameter
|
||||
/// @return _cookies And cookies with nutella
|
||||
/// @return The result of the multiplication
|
||||
/// @return _milk And milk with nutella
|
||||
function mul(uint a, uint second) public returns (uint _cookies, uint, uint _milk) {
|
||||
uint mul = a * 7;
|
||||
uint milk = 4;
|
||||
return (mul, second, milk);
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
char const* natspec = "{"
|
||||
"\"methods\":{"
|
||||
" \"mul(uint256,uint256)\":{ \n"
|
||||
" \"details\": \"Multiplies a number by 7 and adds second parameter\",\n"
|
||||
" \"params\": {\n"
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"returns\": {\n"
|
||||
" \"_cookies\": \"And cookies with nutella\",\n"
|
||||
" \"_1\": \"The result of the multiplication\",\n"
|
||||
" \"_milk\": \"And milk with nutella\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}}";
|
||||
|
||||
checkNatspec(sourceCode, "test", natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_return_desc_multiple_unamed)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
@@ -445,9 +518,9 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_multiple_unamed)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"_1\": \"The result of the multiplication\",\n"
|
||||
" \"_2\": \"And cookies with nutella\"\n"
|
||||
" \"returns\": {\n"
|
||||
" \"_0\": \"The result of the multiplication\",\n"
|
||||
" \"_1\": \"And cookies with nutella\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}}";
|
||||
@@ -466,7 +539,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_multiple)
|
||||
/// @return d The result of the multiplication
|
||||
/// @return f And cookies with nutella
|
||||
function mul(uint a, uint second) public returns (uint d, uint f) {
|
||||
uint mul = a * 7;
|
||||
uint mul = a * 7;
|
||||
return (mul, second);
|
||||
}
|
||||
}
|
||||
@@ -480,7 +553,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_multiple)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"returns\": {\n"
|
||||
" \"d\": \"The result of the multiplication\",\n"
|
||||
" \"f\": \"And cookies with nutella\"\n"
|
||||
" }\n"
|
||||
@@ -514,7 +587,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"returns\": {\n"
|
||||
" \"d\": \"The result of the multiplication and cookies with nutella\",\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
@@ -549,7 +622,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
|
||||
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
|
||||
" \"second\": \"Documentation for the second parameter\"\n"
|
||||
" },\n"
|
||||
" \"return\": {\n"
|
||||
" \"returns\": {\n"
|
||||
" \"d\": \"The result of the multiplication and cookies with nutella\",\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
@@ -558,6 +631,21 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
|
||||
checkNatspec(sourceCode, "test", natspec, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_documenting_no_return_paramname)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
/// @dev Multiplies a number by 7 and adds second parameter
|
||||
/// @param a Documentation for the first parameter
|
||||
/// @param second Documentation for the second parameter
|
||||
/// @return
|
||||
function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
|
||||
}
|
||||
)";
|
||||
|
||||
expectNatspecError(sourceCode);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
@@ -871,7 +959,7 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function)
|
||||
"a" : "Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines",
|
||||
"second" : "Documentation for the second parameter"
|
||||
},
|
||||
"return" : {
|
||||
"returns" : {
|
||||
"d": "The result of the multiplication and cookies with nutella"
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user