aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-05 01:12:52 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-05 01:12:52 +0800
commitb6c8e9e011141ef82c27e9df299e7a9771069133 (patch)
treee046e7388a78f0158ce40b53ce166033a9dcfde6
parentc7e67ee59e7fe106f444d04d2e955fa17892f186 (diff)
downloaddexon-solidity-b6c8e9e011141ef82c27e9df299e7a9771069133.tar.gz
dexon-solidity-b6c8e9e011141ef82c27e9df299e7a9771069133.tar.zst
dexon-solidity-b6c8e9e011141ef82c27e9df299e7a9771069133.zip
Natspec @return tag parsing
- Also omitting tags from the output JSON file if they are missing instead of providing an empty string for their value
-rw-r--r--solidityNatspecJSON.cpp74
1 files changed, 72 insertions, 2 deletions
diff --git a/solidityNatspecJSON.cpp b/solidityNatspecJSON.cpp
index 5894f3b0..2c4be219 100644
--- a/solidityNatspecJSON.cpp
+++ b/solidityNatspecJSON.cpp
@@ -100,8 +100,7 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
char const* devNatspec = "{"
"\"methods\":{"
" \"mul\":{ \n"
- " \"details\": \"Multiplies a number by 7\",\n"
- " \"params\": {}\n"
+ " \"details\": \"Multiplies a number by 7\"\n"
" }\n"
" }\n"
"}}";
@@ -175,6 +174,24 @@ BOOST_AUTO_TEST_CASE(user_empty_contract)
checkNatspec(sourceCode, natspec, true);
}
+BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
+{
+ char const* sourceCode = "contract test {\n"
+ " function mul(uint a) returns(uint d) { return a * 7; }\n"
+ " function sub(int input) returns(int d)\n"
+ " {\n"
+ " return input - 3;\n"
+ " }\n"
+ "}\n";
+
+ char const* devNatspec = "{\"methods\":{}}";
+
+ char const* userNatspec = "{\"methods\":{}}";
+
+ checkNatspec(sourceCode, devNatspec, false);
+ checkNatspec(sourceCode, userNatspec, true);
+}
+
BOOST_AUTO_TEST_CASE(dev_multiple_params)
{
char const* sourceCode = "contract test {\n"
@@ -272,6 +289,59 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
checkNatspec(sourceCode, natspec, false);
}
+BOOST_AUTO_TEST_CASE(dev_return)
+{
+ char const* sourceCode = "contract test {\n"
+ " /// @dev Multiplies a number by 7 and adds second parameter\n"
+ " /// @param a Documentation for the first parameter starts here.\n"
+ " /// Since it's a really complicated parameter we need 2 lines\n"
+ " /// @param second Documentation for the second parameter\n"
+ " /// @return The result of the multiplication\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ "\"methods\":{"
+ " \"mul\":{ \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"
+ " \"return\": \"The result of the multiplication\"\n"
+ " }\n"
+ "}}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
+BOOST_AUTO_TEST_CASE(dev_multiline_return)
+{
+ char const* sourceCode = "contract test {\n"
+ " /// @dev Multiplies a number by 7 and adds second parameter\n"
+ " /// @param a Documentation for the first parameter starts here.\n"
+ " /// Since it's a really complicated parameter we need 2 lines\n"
+ " /// @param second Documentation for the second parameter\n"
+ " /// @return The result of the multiplication\n"
+ " /// and cookies with nutella\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ "\"methods\":{"
+ " \"mul\":{ \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"
+ " \"return\": \"The result of the multiplication and cookies with nutella\"\n"
+ " }\n"
+ "}}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}