aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityNatspecJSON.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-26 22:13:36 +0800
committerchriseth <c@ethdev.com>2015-10-26 22:24:36 +0800
commitb4f561680a2a5169d1245271245e2b71822cb73a (patch)
tree6e3acecc9bbe825400e4297a32ff641df27d1943 /test/libsolidity/SolidityNatspecJSON.cpp
parentd6e77ce0e1da577e5f2c000f89b4fba3505d84a0 (diff)
downloaddexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.gz
dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.zst
dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.zip
Store docstrings in AST annotations.
Diffstat (limited to 'test/libsolidity/SolidityNatspecJSON.cpp')
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index ee67dd66..8c0c2098 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -63,6 +63,12 @@ public:
);
}
+ void expectNatspecError(std::string const& _code)
+ {
+ BOOST_CHECK(!m_compilerStack.parse(_code));
+ BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError));
+ }
+
private:
CompilerStack m_compilerStack;
Json::Reader m_reader;
@@ -543,6 +549,31 @@ BOOST_AUTO_TEST_CASE(empty_comment)
checkNatspec(sourceCode, natspec, true);
}
+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";
+
+ expectNatspecError(sourceCode);
+}
+
+BOOST_AUTO_TEST_CASE(dev_documenting_nonexistant_param)
+{
+ char const* sourceCode = "contract test {\n"
+ " /// @dev Multiplies a number by 7 and adds second parameter\n"
+ " /// @param a Documentation for the first parameter\n"
+ " /// @param not_existing Documentation for the second parameter\n"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ expectNatspecError(sourceCode);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}