mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add test for invalid ast id.
This commit is contained in:
@@ -848,6 +848,84 @@ BOOST_AUTO_TEST_CASE(astid_reset)
|
||||
BOOST_CHECK(debugDataOf(result->statements.at(1))->astID == nullopt);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(astid_multi)
|
||||
{
|
||||
ErrorList errorList;
|
||||
ErrorReporter reporter(errorList);
|
||||
auto const sourceText = R"(
|
||||
/// @src -1:-1:-1 @ast-id 7 @src 1:1:1 @ast-id 8
|
||||
{}
|
||||
)";
|
||||
EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{});
|
||||
shared_ptr<Block> result = parse(sourceText, dialect, reporter);
|
||||
BOOST_REQUIRE(!!result);
|
||||
BOOST_CHECK(result->debugData->astID == int64_t(8));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(astid_invalid)
|
||||
{
|
||||
ErrorList errorList;
|
||||
ErrorReporter reporter(errorList);
|
||||
auto const sourceText = R"(
|
||||
/// @src -1:-1:-1 @ast-id abc @src 1:1:1
|
||||
{}
|
||||
)";
|
||||
EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{});
|
||||
shared_ptr<Block> result = parse(sourceText, dialect, reporter);
|
||||
BOOST_REQUIRE(!!result);
|
||||
BOOST_REQUIRE(errorList.size() == 1);
|
||||
BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError);
|
||||
BOOST_TEST(errorList[0]->errorId() == 1749_error);
|
||||
CHECK_LOCATION(result->debugData->location, "", -1, -1);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(astid_too_large)
|
||||
{
|
||||
ErrorList errorList;
|
||||
ErrorReporter reporter(errorList);
|
||||
auto const sourceText = R"(
|
||||
/// @ast-id 9223372036854775808
|
||||
{}
|
||||
)";
|
||||
EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{});
|
||||
shared_ptr<Block> result = parse(sourceText, dialect, reporter);
|
||||
BOOST_REQUIRE(!!result);
|
||||
BOOST_REQUIRE(errorList.size() == 1);
|
||||
BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError);
|
||||
BOOST_TEST(errorList[0]->errorId() == 1749_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(astid_way_too_large)
|
||||
{
|
||||
ErrorList errorList;
|
||||
ErrorReporter reporter(errorList);
|
||||
auto const sourceText = R"(
|
||||
/// @ast-id 999999999999999999999999999999999999999
|
||||
{}
|
||||
)";
|
||||
EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{});
|
||||
shared_ptr<Block> result = parse(sourceText, dialect, reporter);
|
||||
BOOST_REQUIRE(!!result);
|
||||
BOOST_REQUIRE(errorList.size() == 1);
|
||||
BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError);
|
||||
BOOST_TEST(errorList[0]->errorId() == 1749_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(astid_not_fully_numeric)
|
||||
{
|
||||
ErrorList errorList;
|
||||
ErrorReporter reporter(errorList);
|
||||
auto const sourceText = R"(
|
||||
/// @ast-id 9x
|
||||
{}
|
||||
)";
|
||||
EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{});
|
||||
shared_ptr<Block> result = parse(sourceText, dialect, reporter);
|
||||
BOOST_REQUIRE(!!result);
|
||||
BOOST_REQUIRE(errorList.size() == 1);
|
||||
BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError);
|
||||
BOOST_TEST(errorList[0]->errorId() == 1749_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(customSourceLocations_multiple_src_tags_on_one_line)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user