aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-04 01:06:07 +0800
committerchriseth <chris@ethereum.org>2018-12-04 21:49:16 +0800
commit961026347d9749c7c679be503363391c7bb14673 (patch)
tree9e6ffa8d1ea71eb935832c7b2f124bce61fd9a54
parent1746366bb6f769ab68acbcedf3b03037ea19173c (diff)
downloaddexon-solidity-961026347d9749c7c679be503363391c7bb14673.tar.gz
dexon-solidity-961026347d9749c7c679be503363391c7bb14673.tar.zst
dexon-solidity-961026347d9749c7c679be503363391c7bb14673.zip
Use dialect option in yul parser tests.
-rw-r--r--test/libyul/Parser.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp
index bbaf01bf..95ae8959 100644
--- a/test/libyul/Parser.cpp
+++ b/test/libyul/Parser.cpp
@@ -47,12 +47,12 @@ namespace test
namespace
{
-bool parse(string const& _source, ErrorReporter& errorReporter)
+bool parse(string const& _source, Dialect const& _dialect, ErrorReporter& errorReporter)
{
try
{
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)
{
yul::AsmAnalysisInfo analysisInfo;
@@ -61,7 +61,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
errorReporter,
dev::test::Options::get().evmVersion(),
boost::none,
- yul::Dialect::yul()
+ _dialect
)).analyze(*parserResult);
}
}
@@ -72,11 +72,11 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
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;
ErrorReporter errorReporter(errors);
- if (!parse(_source, errorReporter))
+ if (!parse(_source, _dialect, errorReporter))
{
BOOST_REQUIRE(!errors.empty());
BOOST_CHECK_EQUAL(errors.size(), 1);
@@ -97,29 +97,31 @@ boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _all
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);
return *error;
}
}
-#define CHECK_ERROR(text, typ, substring) \
+#define CHECK_ERROR_DIALECT(text, typ, substring, dialect) \
do \
{ \
- Error err = expectError((text), false); \
+ Error err = expectError((text), dialect, false); \
BOOST_CHECK(err.type() == (Error::Type::typ)); \
BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \
} while(0)
+#define CHECK_ERROR(text, typ, substring) CHECK_ERROR_DIALECT(text, typ, substring, Dialect::yul())
+
BOOST_AUTO_TEST_SUITE(YulParser)
BOOST_AUTO_TEST_CASE(smoke_test)