aboutsummaryrefslogtreecommitdiffstats
path: root/solidityParser.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-11-28 07:40:00 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-11-28 07:40:00 +0800
commitc8fa23735f7023dd342fe41aa864aa9b91a4845d (patch)
tree32996e1f88f27c6aa274189d9141737672b162f4 /solidityParser.cpp
parent2b30e1ef2c23cf5574d7d7a9155150c6063c9c9c (diff)
downloaddexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar.gz
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar.bz2
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar.lz
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar.xz
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.tar.zst
dexon-solidity-c8fa23735f7023dd342fe41aa864aa9b91a4845d.zip
Adding solidity natspec comment inside function body
Diffstat (limited to 'solidityParser.cpp')
-rw-r--r--solidityParser.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/solidityParser.cpp b/solidityParser.cpp
index e05b8858..3a95ec06 100644
--- a/solidityParser.cpp
+++ b/solidityParser.cpp
@@ -172,6 +172,36 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
" and it has 2 lines");
}
+BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
+{
+ ASTPointer<ContractDefinition> contract;
+ ASTPointer<FunctionDefinition> function;
+ char const* text = "contract test {\n"
+ " /// fun1 description\n"
+ " function fun1(uint256 a) {\n"
+ " var b;\n"
+ " /// I should not interfere with actual natspec comments\n"
+ " uint256 c;\n"
+ " mapping(address=>hash) d;\n"
+ " string name = \"Solidity\";"
+ " }\n"
+ " uint256 stateVar;\n"
+ " /// This is a test function\n"
+ " /// and it has 2 lines\n"
+ " function fun(hash hashin) returns (hash hashout) {}\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(contract = parseText(text));
+ auto functions = contract->getDefinedFunctions();
+
+ BOOST_CHECK_NO_THROW(function = functions.at(0));
+ BOOST_CHECK_EQUAL(function->getDocumentation(), " fun1 description");
+
+ BOOST_CHECK_NO_THROW(function = functions.at(1));
+ BOOST_CHECK_EQUAL(function->getDocumentation(),
+ " This is a test function\n"
+ " and it has 2 lines");
+}
+
BOOST_AUTO_TEST_CASE(struct_definition)
{
char const* text = "contract test {\n"