mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[isoltest] Replace storage command with 'storage_empty' builtin.
This commit is contained in:
@@ -294,9 +294,8 @@ struct FunctionCall
|
||||
LowLevel,
|
||||
/// Marks a library deployment call.
|
||||
Library,
|
||||
/// Check that the storage of the current contract is empty or non-empty.
|
||||
Storage,
|
||||
/// Call to a builtin.
|
||||
/// Builtins get registered in `SemanticTest::initializeBuiltins()`.
|
||||
Builtin
|
||||
};
|
||||
Kind kind = Kind::Regular;
|
||||
|
||||
@@ -106,21 +106,6 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
|
||||
call.kind = FunctionCall::Kind::Library;
|
||||
call.expectations.failure = false;
|
||||
}
|
||||
else if (accept(Token::Storage, true))
|
||||
{
|
||||
expect(Token::Colon);
|
||||
call.expectations.failure = false;
|
||||
call.expectations.result.push_back(Parameter());
|
||||
// empty / non-empty is encoded as false / true
|
||||
if (m_scanner.currentLiteral() == "empty")
|
||||
call.expectations.result.back().rawBytes = bytes(1, uint8_t(false));
|
||||
else if (m_scanner.currentLiteral() == "nonempty")
|
||||
call.expectations.result.back().rawBytes = bytes(1, uint8_t(true));
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Expected \"empty\" or \"nonempty\"."));
|
||||
call.kind = FunctionCall::Kind::Storage;
|
||||
m_scanner.scanNextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
bool lowLevelCall = false;
|
||||
|
||||
@@ -958,28 +958,6 @@ BOOST_AUTO_TEST_CASE(library)
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_storage)
|
||||
{
|
||||
char const* source = R"(
|
||||
// storage: empty
|
||||
)";
|
||||
auto const calls = parse(source);
|
||||
BOOST_REQUIRE_EQUAL(calls.size(), 1);
|
||||
BOOST_CHECK(calls.at(0).kind == FunctionCall::Kind::Storage);
|
||||
BOOST_CHECK(calls.at(0).expectations.result.front().rawBytes == bytes(1, 0));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(nonempty_storage)
|
||||
{
|
||||
char const* source = R"(
|
||||
// storage: nonempty
|
||||
)";
|
||||
auto const calls = parse(source);
|
||||
BOOST_REQUIRE_EQUAL(calls.size(), 1);
|
||||
BOOST_CHECK(calls.at(0).kind == FunctionCall::Kind::Storage);
|
||||
BOOST_CHECK(calls.at(0).expectations.result.front().rawBytes == bytes(1, 1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
@@ -61,23 +61,6 @@ string TestFunctionCall::format(
|
||||
stream << _linePrefix << newline << ws << "library:" << ws << m_call.signature;
|
||||
return;
|
||||
}
|
||||
else if (m_call.kind == FunctionCall::Kind::Storage)
|
||||
{
|
||||
stream << _linePrefix << newline << ws << "storage" << colon << ws;
|
||||
soltestAssert(m_rawBytes.size() == 1, "");
|
||||
soltestAssert(m_call.expectations.rawBytes().size() == 1, "");
|
||||
bool isEmpty =
|
||||
_renderMode == RenderMode::ActualValuesExpectedGas ?
|
||||
m_rawBytes.front() == 0 :
|
||||
m_call.expectations.rawBytes().front() == 0;
|
||||
string output = isEmpty ? "empty" : "nonempty";
|
||||
if (_renderMode == RenderMode::ActualValuesExpectedGas && !matchesExpectation())
|
||||
AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << output;
|
||||
else
|
||||
stream << output;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// Formats the function signature. This is the same independent from the display-mode.
|
||||
stream << _linePrefix << newline << ws << m_call.signature;
|
||||
|
||||
Reference in New Issue
Block a user