Merge pull request #6221 from ethereum/soltest-signature-struct-arrays

[soltest] Allow struct array in function signatures
This commit is contained in:
Daniel Kirchner 2019-03-11 15:32:42 +01:00 committed by GitHub
commit f805939429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View File

@ -22,6 +22,7 @@ Bugfixes:
Build System:
* Soltest: Add support for arrays in function signatures.
* Soltest: Add support for struct arrays in function signatures.
### 0.5.5 (2019-03-05)

View File

@ -318,10 +318,8 @@ string TestFileParser::parseIdentifierOrTuple()
{
string identOrTuple;
if (accept(Token::Identifier))
auto parseArrayDimensions = [&]()
{
identOrTuple = m_scanner.currentLiteral();
expect(Token::Identifier);
while (accept(Token::LBrack))
{
identOrTuple += formatToken(Token::LBrack);
@ -331,6 +329,13 @@ string TestFileParser::parseIdentifierOrTuple()
identOrTuple += formatToken(Token::RBrack);
expect(Token::RBrack);
}
};
if (accept(Token::Identifier))
{
identOrTuple = m_scanner.currentLiteral();
expect(Token::Identifier);
parseArrayDimensions();
return identOrTuple;
}
expect(Token::LParen);
@ -345,6 +350,8 @@ string TestFileParser::parseIdentifierOrTuple()
}
expect(Token::RParen);
identOrTuple += formatToken(Token::RParen);
parseArrayDimensions();
return identOrTuple;
}

View File

@ -474,6 +474,23 @@ BOOST_AUTO_TEST_CASE(call_signature_array)
testFunctionCall(calls.at(2), Mode::SingleLine, "f(uint256[3][][],uint8[9])", false);
}
BOOST_AUTO_TEST_CASE(call_signature_struct_array)
{
char const* source = R"(
// f((uint256)[]) ->
// f((uint256)[3]) ->
// f((uint256, uint8)[3]) ->
// f((uint256)[3][][], (uint8, bool)[9]) ->
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 4);
testFunctionCall(calls.at(0), Mode::SingleLine, "f((uint256)[])", false);
testFunctionCall(calls.at(1), Mode::SingleLine, "f((uint256)[3])", false);
testFunctionCall(calls.at(2), Mode::SingleLine, "f((uint256,uint8)[3])", false);
testFunctionCall(calls.at(3), Mode::SingleLine, "f((uint256)[3][][],(uint8,bool)[9])", false);
}
BOOST_AUTO_TEST_CASE(call_signature_valid)
{
char const* source = R"(