diff options
author | Christian <c@ethdev.com> | 2014-12-05 22:27:07 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-05 22:27:07 +0800 |
commit | 8e96de4f9c09806b54806faaf7614aef6a2a5453 (patch) | |
tree | b2040fd085779fbec0028b116e8f2121f2a16ec4 /solidityJSONInterfaceTest.cpp | |
parent | 69da6df77d3e61b7b1feff490716e5bda2e1f977 (diff) | |
parent | 80ad71576459f0401d838aa97b62bc40607dbafb (diff) | |
download | dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar.gz dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar.bz2 dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar.lz dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar.xz dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.tar.zst dexon-solidity-8e96de4f9c09806b54806faaf7614aef6a2a5453.zip |
Merge remote-tracking branch 'ethereum/develop' into sol_import
Conflicts:
libsolidity/CompilerStack.cpp
libsolidity/CompilerStack.h
solc/main.cpp
Diffstat (limited to 'solidityJSONInterfaceTest.cpp')
-rw-r--r-- | solidityJSONInterfaceTest.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/solidityJSONInterfaceTest.cpp b/solidityJSONInterfaceTest.cpp index 1a443087..2b7e60d3 100644 --- a/solidityJSONInterfaceTest.cpp +++ b/solidityJSONInterfaceTest.cpp @@ -23,6 +23,7 @@ #include <boost/test/unit_test.hpp> #include <libsolidity/CompilerStack.h> #include <jsonrpc/json/json.h> +#include <libdevcore/Exceptions.h> namespace dev { @@ -34,23 +35,37 @@ namespace test class InterfaceChecker { public: - bool checkInterface(std::string const& _code, std::string const& _expectedInterfaceString) + void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString) { - m_compilerStack.parse(_code); - std::string generatedInterfaceString = m_compilerStack.getInterface(); + try + { + m_compilerStack.parse(_code); + } + catch (const std::exception& e) + { + std::string const* extra = boost::get_error_info<errinfo_comment>(e); + std::string msg = std::string("Parsing contract failed with: ") + + e.what() + std::string("\n"); + if (extra) + msg += *extra; + BOOST_FAIL(msg); + } + std::string generatedInterfaceString = m_compilerStack.getJsonDocumentation("", ABI_INTERFACE); Json::Value generatedInterface; m_reader.parse(generatedInterfaceString, generatedInterface); Json::Value expectedInterface; m_reader.parse(_expectedInterfaceString, expectedInterface); - return expectedInterface == generatedInterface; + BOOST_CHECK_MESSAGE(expectedInterface == generatedInterface, + "Expected " << _expectedInterfaceString << + "\n but got:\n" << generatedInterfaceString); } - + private: CompilerStack m_compilerStack; Json::Reader m_reader; }; -BOOST_FIXTURE_TEST_SUITE(SolidityCompilerJSONInterfaceOutput, InterfaceChecker) +BOOST_FIXTURE_TEST_SUITE(SolidityABIJSON, InterfaceChecker) BOOST_AUTO_TEST_CASE(basic_test) { @@ -76,7 +91,7 @@ BOOST_AUTO_TEST_CASE(basic_test) } ])"; - BOOST_CHECK(checkInterface(sourceCode, interface)); + checkInterface(sourceCode, interface); } BOOST_AUTO_TEST_CASE(empty_contract) @@ -86,7 +101,7 @@ BOOST_AUTO_TEST_CASE(empty_contract) char const* interface = "[]"; - BOOST_CHECK(checkInterface(sourceCode, interface)); + checkInterface(sourceCode, interface); } BOOST_AUTO_TEST_CASE(multiple_methods) @@ -95,7 +110,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods) " function f(uint a) returns(uint d) { return a * 7; }\n" " function g(uint b) returns(uint e) { return b * 8; }\n" "}\n"; - + char const* interface = R"([ { "name": "f", @@ -129,7 +144,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods) } ])"; - BOOST_CHECK(checkInterface(sourceCode, interface)); + checkInterface(sourceCode, interface); } BOOST_AUTO_TEST_CASE(multiple_params) @@ -160,7 +175,7 @@ BOOST_AUTO_TEST_CASE(multiple_params) } ])"; - BOOST_CHECK(checkInterface(sourceCode, interface)); + checkInterface(sourceCode, interface); } BOOST_AUTO_TEST_CASE(multiple_methods_order) @@ -170,7 +185,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order) " function f(uint a) returns(uint d) { return a * 7; }\n" " function c(uint b) returns(uint e) { return b * 8; }\n" "}\n"; - + char const* interface = R"([ { "name": "c", @@ -203,8 +218,8 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order) ] } ])"; - - BOOST_CHECK(checkInterface(sourceCode, interface)); + + checkInterface(sourceCode, interface); } BOOST_AUTO_TEST_SUITE_END() |