aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-03-06 07:20:20 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-03-06 21:37:20 +0800
commit10c666fb52271f1100888676e70ad43aa65c8cdf (patch)
tree291a349b1be890252d0f0c15042c48b79c6f1e08
parent1234526c938504134b6b86252353ab5e2ae6319f (diff)
downloaddexon-solidity-10c666fb52271f1100888676e70ad43aa65c8cdf.tar.gz
dexon-solidity-10c666fb52271f1100888676e70ad43aa65c8cdf.tar.zst
dexon-solidity-10c666fb52271f1100888676e70ad43aa65c8cdf.zip
Extracting ETH_TEST_REQUIRE_NO_THROW() from my other PR
-rw-r--r--SolidityExpressionCompiler.cpp25
1 files changed, 21 insertions, 4 deletions
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<string> const& _namespacedName,
- NameAndTypeResolver const& _resolver)
+Declaration const& resolveDeclaration(
+ vector<string> 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<vector<string>> _
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
- BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
+ ETH_TEST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract), "Resolving names failed");
inheritanceHierarchy = vector<ContractDefinition const*>(1, contract);
}
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
- BOOST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract));
+ ETH_TEST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract), "Checking type Requirements failed");
}
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))