mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Store docstrings in AST annotations.
This commit is contained in:
@@ -4735,32 +4735,6 @@ BOOST_AUTO_TEST_CASE(bytes_memory_index_access)
|
||||
) == encodeArgs(u256(data.size()), string("d")));
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
compileRequireError(sourceCode, Error::Type::DocstringParsingError);
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
compileRequireError(sourceCode, Error::Type::DocstringParsingError);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(storage_array_ref)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
||||
@@ -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()
|
||||
|
||||
}
|
||||
|
||||
@@ -67,28 +67,6 @@ public:
|
||||
return m_output;
|
||||
}
|
||||
|
||||
void compileRequireError(std::string const& _sourceCode, Error::Type _type)
|
||||
{
|
||||
m_compiler.reset(false, m_addStandardSources);
|
||||
m_compiler.addSource("", _sourceCode);
|
||||
bool foundError = false;
|
||||
try
|
||||
{
|
||||
m_compiler.compile(m_optimize, m_optimizeRuns);
|
||||
BOOST_REQUIRE(Error::containsErrorOfType(m_compiler.errors(), _type));
|
||||
}
|
||||
catch (Error const& _e)
|
||||
{
|
||||
BOOST_REQUIRE(_e.type() == _type);
|
||||
foundError = true;
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
BOOST_REQUIRE(false);
|
||||
}
|
||||
BOOST_REQUIRE(foundError);
|
||||
}
|
||||
|
||||
bytes const& compileAndRun(
|
||||
std::string const& _sourceCode,
|
||||
u256 const& _value = 0,
|
||||
|
||||
Reference in New Issue
Block a user