Merge pull request #13166 from ethereum/libraryNameIsoltestSemanticTestExpectations

Fix for library name updates in isoltest semantics tests.
This commit is contained in:
Daniel Kirchner 2022-06-17 17:20:08 +02:00 committed by GitHub
commit be470c16fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View File

@ -386,10 +386,7 @@ TestCase::TestResult SemanticTest::runTest(
// For convenience, in semantic tests we assume that an unqualified name like `L` is equivalent to one
// with an empty source unit name (`:L`). This is fine because the compiler never uses unqualified
// names in the Yul code it produces and does not allow `linkersymbol()` at all in inline assembly.
if (test.call().signature.find(':') == string::npos)
libraries[":" + test.call().signature] = m_contractAddress;
else
libraries[test.call().signature] = m_contractAddress;
libraries[test.call().libraryFile + ":" + test.call().signature] = m_contractAddress;
continue;
}
else

View File

@ -268,6 +268,7 @@ struct FunctionValue
struct FunctionCall
{
/// Signature of the function call, e.g. `f(uint256, uint256)`.
/// For a library deployment, this contains the library name.
std::string signature;
/// Optional value that can be sent with the call.
/// Value is expressed in wei, smallest unit of ether
@ -313,6 +314,8 @@ struct FunctionCall
std::vector<std::string> expectedSideEffects{};
/// A textual representation of the actual side-effect of the function call.
std::vector<std::string> actualSideEffects{};
/// File name of the library. Always empty, unless this is a library deployment call.
std::string libraryFile{};
};
using Builtin = std::function<std::optional<bytes>(FunctionCall const&)>;

View File

@ -107,15 +107,15 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
string libraryName;
if (accept(Token::String))
{
libraryName = m_scanner.currentLiteral();
call.libraryFile = m_scanner.currentLiteral();
expect(Token::String);
expect(Token::Colon);
libraryName += ':' + m_scanner.currentLiteral();
libraryName += m_scanner.currentLiteral();
expect(Token::Identifier);
}
else if (accept(Token::Colon, true))
{
libraryName = ':' + m_scanner.currentLiteral();
libraryName = m_scanner.currentLiteral();
expect(Token::Identifier);
}
else

View File

@ -58,7 +58,10 @@ string TestFunctionCall::format(
if (m_call.kind == FunctionCall::Kind::Library)
{
stream << _linePrefix << newline << ws << "library:" << ws << m_call.signature;
stream << _linePrefix << newline << ws << "library:" << ws;
if (!m_call.libraryFile.empty())
stream << "\"" << m_call.libraryFile << "\":";
stream << m_call.signature;
return;
}