mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Bring soltestAssert() up to date with solAssert()
- Allow omitting description. - Provide a default description. - Use a custom exception type derived from util::Exception rather than std::exception.
This commit is contained in:
parent
31b5485779
commit
0bb885dab2
@ -15,20 +15,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <libsolutil/AnsiColorized.h>
|
||||
#include <libsolutil/Assertions.h>
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
#include <boost/preprocessor/facilities/overload.hpp>
|
||||
|
||||
namespace solidity::frontend::test
|
||||
{
|
||||
|
||||
#define soltestAssert(CONDITION, DESCRIPTION) \
|
||||
do \
|
||||
{ \
|
||||
if (!(CONDITION)) \
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(DESCRIPTION)); \
|
||||
} \
|
||||
while (false)
|
||||
struct InternalSoltestError: virtual util::Exception {};
|
||||
|
||||
#if !BOOST_PP_VARIADICS_MSVC
|
||||
#define soltestAssert(...) BOOST_PP_OVERLOAD(soltestAssert_,__VA_ARGS__)(__VA_ARGS__)
|
||||
#else
|
||||
#define soltestAssert(...) BOOST_PP_CAT(BOOST_PP_OVERLOAD(soltestAssert_,__VA_ARGS__)(__VA_ARGS__),BOOST_PP_EMPTY())
|
||||
#endif
|
||||
|
||||
#define soltestAssert_1(CONDITION) \
|
||||
soltestAssert_2((CONDITION), "")
|
||||
|
||||
#define soltestAssert_2(CONDITION, DESCRIPTION) \
|
||||
assertThrowWithDefaultDescription( \
|
||||
(CONDITION), \
|
||||
::solidity::frontend::test::InternalSoltestError, \
|
||||
(DESCRIPTION), \
|
||||
"Soltest assertion failed" \
|
||||
)
|
||||
|
||||
class TestParserError: virtual public util::Exception
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user