mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6221 from ethereum/soltest-signature-struct-arrays
[soltest] Allow struct array in function signatures
This commit is contained in:
commit
f805939429
@ -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)
|
||||
|
@ -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"(
|
||||
|
Loading…
Reference in New Issue
Block a user