diff --git a/test/libsolidity/util/SoltestErrors.h b/test/libsolidity/util/SoltestErrors.h index e223f714b..849a8b34e 100644 --- a/test/libsolidity/util/SoltestErrors.h +++ b/test/libsolidity/util/SoltestErrors.h @@ -15,20 +15,35 @@ #pragma once #include +#include #include #include +#include +#include +#include + 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 {