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
3 changed files with 28 additions and 3 deletions
+10 -3
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;
}
@@ -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"(