mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use dialect option in yul parser tests.
This commit is contained in:
parent
1746366bb6
commit
961026347d
@ -47,12 +47,12 @@ namespace test
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
bool parse(string const& _source, ErrorReporter& errorReporter)
|
bool parse(string const& _source, Dialect const& _dialect, ErrorReporter& errorReporter)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto scanner = make_shared<Scanner>(CharStream(_source, ""));
|
auto scanner = make_shared<Scanner>(CharStream(_source, ""));
|
||||||
auto parserResult = yul::Parser(errorReporter, yul::Dialect::yul()).parse(scanner, false);
|
auto parserResult = yul::Parser(errorReporter, _dialect).parse(scanner, false);
|
||||||
if (parserResult)
|
if (parserResult)
|
||||||
{
|
{
|
||||||
yul::AsmAnalysisInfo analysisInfo;
|
yul::AsmAnalysisInfo analysisInfo;
|
||||||
@ -61,7 +61,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
|
|||||||
errorReporter,
|
errorReporter,
|
||||||
dev::test::Options::get().evmVersion(),
|
dev::test::Options::get().evmVersion(),
|
||||||
boost::none,
|
boost::none,
|
||||||
yul::Dialect::yul()
|
_dialect
|
||||||
)).analyze(*parserResult);
|
)).analyze(*parserResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,11 +72,11 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
|
boost::optional<Error> parseAndReturnFirstError(string const& _source, Dialect const& _dialect, bool _allowWarnings = true)
|
||||||
{
|
{
|
||||||
ErrorList errors;
|
ErrorList errors;
|
||||||
ErrorReporter errorReporter(errors);
|
ErrorReporter errorReporter(errors);
|
||||||
if (!parse(_source, errorReporter))
|
if (!parse(_source, _dialect, errorReporter))
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(!errors.empty());
|
BOOST_REQUIRE(!errors.empty());
|
||||||
BOOST_CHECK_EQUAL(errors.size(), 1);
|
BOOST_CHECK_EQUAL(errors.size(), 1);
|
||||||
@ -97,29 +97,31 @@ boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _all
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool successParse(std::string const& _source, bool _allowWarnings = true)
|
bool successParse(std::string const& _source, Dialect const& _dialect = Dialect::yul(), bool _allowWarnings = true)
|
||||||
{
|
{
|
||||||
return !parseAndReturnFirstError(_source, _allowWarnings);
|
return !parseAndReturnFirstError(_source, _dialect, _allowWarnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error expectError(std::string const& _source, bool _allowWarnings = false)
|
Error expectError(std::string const& _source, Dialect const& _dialect = Dialect::yul(), bool _allowWarnings = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto error = parseAndReturnFirstError(_source, _allowWarnings);
|
auto error = parseAndReturnFirstError(_source, _dialect, _allowWarnings);
|
||||||
BOOST_REQUIRE(error);
|
BOOST_REQUIRE(error);
|
||||||
return *error;
|
return *error;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_ERROR(text, typ, substring) \
|
#define CHECK_ERROR_DIALECT(text, typ, substring, dialect) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
Error err = expectError((text), false); \
|
Error err = expectError((text), dialect, false); \
|
||||||
BOOST_CHECK(err.type() == (Error::Type::typ)); \
|
BOOST_CHECK(err.type() == (Error::Type::typ)); \
|
||||||
BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \
|
BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define CHECK_ERROR(text, typ, substring) CHECK_ERROR_DIALECT(text, typ, substring, Dialect::yul())
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(YulParser)
|
BOOST_AUTO_TEST_SUITE(YulParser)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(smoke_test)
|
BOOST_AUTO_TEST_CASE(smoke_test)
|
||||||
|
Loading…
Reference in New Issue
Block a user