diff options
author | chriseth <c@ethdev.com> | 2015-10-26 22:13:36 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-26 22:24:36 +0800 |
commit | b4f561680a2a5169d1245271245e2b71822cb73a (patch) | |
tree | 6e3acecc9bbe825400e4297a32ff641df27d1943 /test/libsolidity | |
parent | d6e77ce0e1da577e5f2c000f89b4fba3505d84a0 (diff) | |
download | dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.gz dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.zst dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.zip |
Store docstrings in AST annotations.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 26 | ||||
-rw-r--r-- | test/libsolidity/SolidityNatspecJSON.cpp | 31 | ||||
-rw-r--r-- | test/libsolidity/solidityExecutionFramework.h | 22 |
3 files changed, 31 insertions, 48 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 5f7c6684..fb7c4013 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -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"( 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() } diff --git a/test/libsolidity/solidityExecutionFramework.h b/test/libsolidity/solidityExecutionFramework.h index ed317d2f..4da02eb2 100644 --- a/test/libsolidity/solidityExecutionFramework.h +++ b/test/libsolidity/solidityExecutionFramework.h @@ -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, |