From 10c666fb52271f1100888676e70ad43aa65c8cdf Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 6 Mar 2015 00:20:20 +0100 Subject: Extracting ETH_TEST_REQUIRE_NO_THROW() from my other PR --- SolidityExpressionCompiler.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'SolidityExpressionCompiler.cpp') diff --git a/SolidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp index 3340334f..e9d9a49e 100644 --- a/SolidityExpressionCompiler.cpp +++ b/SolidityExpressionCompiler.cpp @@ -44,6 +44,23 @@ namespace test namespace { +// LTODO: Move to some more generic location. We really need it +/// Make sure that no Exception is thrown during testing. If one is thrown show its info. +/// @param _expression The expression for which to make sure no exceptions are thrown +/// @param _message A message to act as a prefix to the expression's error information +#define ETH_TEST_REQUIRE_NO_THROW(_expression, _message) \ + do { \ + try \ + { \ + _expression; \ + } \ + catch (boost::exception const& _e) \ + { \ + auto msg = std::string(_message) + boost::diagnostic_information(_e); \ + BOOST_FAIL(msg); \ + } \ + }while (0) + /// Helper class that extracts the first expression in an AST. class FirstExpressionExtractor: private ASTVisitor { @@ -72,8 +89,8 @@ private: Expression* m_expression; }; -Declaration const& resolveDeclaration(vector const& _namespacedName, - NameAndTypeResolver const& _resolver) +Declaration const& resolveDeclaration( + vector const& _namespacedName, NameAndTypeResolver const& _resolver) { Declaration const* declaration = nullptr; // bracers are required, cause msvc couldnt handle this macro in for statement @@ -112,13 +129,13 @@ bytes compileFirstExpression(const string& _sourceCode, vector> _ for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract)); + ETH_TEST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract), "Resolving names failed"); inheritanceHierarchy = vector(1, contract); } for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - BOOST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract)); + ETH_TEST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract), "Checking type Requirements failed"); } for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) -- cgit v1.2.3 From 79bbe1e5d81947436b00febd7aa75246c47eabd6 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 6 Mar 2015 12:06:12 +0100 Subject: Move ETH_TEST() Macros to TestHelper.h - Also use them in Solidity Parser --- SolidityExpressionCompiler.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'SolidityExpressionCompiler.cpp') diff --git a/SolidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp index e9d9a49e..7034085e 100644 --- a/SolidityExpressionCompiler.cpp +++ b/SolidityExpressionCompiler.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include "TestHelper.h" using namespace std; @@ -44,23 +44,6 @@ namespace test namespace { -// LTODO: Move to some more generic location. We really need it -/// Make sure that no Exception is thrown during testing. If one is thrown show its info. -/// @param _expression The expression for which to make sure no exceptions are thrown -/// @param _message A message to act as a prefix to the expression's error information -#define ETH_TEST_REQUIRE_NO_THROW(_expression, _message) \ - do { \ - try \ - { \ - _expression; \ - } \ - catch (boost::exception const& _e) \ - { \ - auto msg = std::string(_message) + boost::diagnostic_information(_e); \ - BOOST_FAIL(msg); \ - } \ - }while (0) - /// Helper class that extracts the first expression in an AST. class FirstExpressionExtractor: private ASTVisitor { -- cgit v1.2.3