aboutsummaryrefslogtreecommitdiffstats
path: root/solidityNatspecJSON.cpp
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2014-12-11 19:08:51 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2014-12-11 19:08:51 +0800
commit6a666eed2f6d4e81c7c7411eda1f54e76576e236 (patch)
tree6763fc16d4157852a8b95073a4159733cd5f5b46 /solidityNatspecJSON.cpp
parent2ec5b1770b814a3409bdc5f5de400b3a8b49f2bb (diff)
parent1d17d349797b9267f6d541c812b8eed3a6954977 (diff)
downloaddexon-solidity-6a666eed2f6d4e81c7c7411eda1f54e76576e236.tar.gz
dexon-solidity-6a666eed2f6d4e81c7c7411eda1f54e76576e236.tar.zst
dexon-solidity-6a666eed2f6d4e81c7c7411eda1f54e76576e236.zip
Merge branch 'macox_fixes' into build_enhancement
Conflicts: test/solidityNatspecJSON.cpp
Diffstat (limited to 'solidityNatspecJSON.cpp')
-rw-r--r--solidityNatspecJSON.cpp90
1 files changed, 89 insertions, 1 deletions
diff --git a/solidityNatspecJSON.cpp b/solidityNatspecJSON.cpp
index d66d1294..2c3ded08 100644
--- a/solidityNatspecJSON.cpp
+++ b/solidityNatspecJSON.cpp
@@ -21,8 +21,9 @@
*/
#include <boost/test/unit_test.hpp>
-#include <libsolidity/CompilerStack.h>
#include <jsoncpp/json/json.h>
+#include <libsolidity/CompilerStack.h>
+#include <libsolidity/Exceptions.h>
#include <libdevcore/Exceptions.h>
namespace dev
@@ -393,6 +394,93 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
checkNatspec(sourceCode, natspec, false);
}
+BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
+{
+ char const* sourceCode = "contract test {\n"
+ " /// @dev Mul function\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ " \"methods\":{"
+ " \"mul\":{ \n"
+ " \"details\": \"Mul function\"\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
+BOOST_AUTO_TEST_CASE(dev_contract_doc)
+{
+ char const* sourceCode = " /// @author Lefteris\n"
+ " /// @title Just a test contract\n"
+ "contract test {\n"
+ " /// @dev Mul function\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ " \"author\": \"Lefteris\","
+ " \"title\": \"Just a test contract\","
+ " \"methods\":{"
+ " \"mul\":{ \n"
+ " \"details\": \"Mul function\"\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
+BOOST_AUTO_TEST_CASE(dev_author_at_function)
+{
+ char const* sourceCode = " /// @author Lefteris\n"
+ " /// @title Just a test contract\n"
+ "contract test {\n"
+ " /// @dev Mul function\n"
+ " /// @author John Doe\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ " \"author\": \"Lefteris\","
+ " \"title\": \"Just a test contract\","
+ " \"methods\":{"
+ " \"mul\":{ \n"
+ " \"details\": \"Mul function\",\n"
+ " \"author\": \"John Doe\",\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
+BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
+{
+ char const* sourceCode = " /// @author Lefteris\n"
+ " /// @title Just a test contract\n"
+ "contract test {\n"
+ " /// @dev Mul function\n"
+ " /// @title I really should not be here\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ " \"author\": \"Lefteris\","
+ " \"title\": \"Just a test contract\","
+ " \"methods\":{"
+ " \"mul\":{ \n"
+ " \"details\": \"Mul function\"\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ BOOST_CHECK_THROW(checkNatspec(sourceCode, natspec, false), DocstringParsingError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}