mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not evaluate strings if assertion succeeds.
This commit is contained in:
parent
652d8dab19
commit
a3b01eca27
@ -73,27 +73,19 @@ inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char con
|
|||||||
/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
|
/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
|
||||||
/// Do NOT supply an exception object as the second parameter.
|
/// Do NOT supply an exception object as the second parameter.
|
||||||
#define assertThrow(_condition, _ExceptionType, _description) \
|
#define assertThrow(_condition, _ExceptionType, _description) \
|
||||||
::dev::assertThrowAux<_ExceptionType>(!!(_condition), _description, __LINE__, __FILE__, ETH_FUNC)
|
do \
|
||||||
|
{ \
|
||||||
|
if (!(_condition)) \
|
||||||
|
::boost::throw_exception( \
|
||||||
|
_ExceptionType() << \
|
||||||
|
::dev::errinfo_comment(_description) << \
|
||||||
|
::boost::throw_function(ETH_FUNC) << \
|
||||||
|
::boost::throw_file(__FILE__) << \
|
||||||
|
::boost::throw_line(__LINE__) \
|
||||||
|
); \
|
||||||
|
} \
|
||||||
|
while (false)
|
||||||
|
|
||||||
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
|
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
|
||||||
|
|
||||||
template <class _ExceptionType>
|
|
||||||
inline void assertThrowAux(
|
|
||||||
bool _condition,
|
|
||||||
::std::string const& _errorDescription,
|
|
||||||
unsigned _line,
|
|
||||||
char const* _file,
|
|
||||||
char const* _function
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!_condition)
|
|
||||||
::boost::throw_exception(
|
|
||||||
_ExceptionType() <<
|
|
||||||
::dev::errinfo_comment(_errorDescription) <<
|
|
||||||
::boost::throw_function(_function) <<
|
|
||||||
::boost::throw_file(_file) <<
|
|
||||||
::boost::throw_line(_line)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user