Merge pull request #6204 from ethereum/soltest-signature-arrays

[soltest] Add support for arrays in function signatures
This commit is contained in:
chriseth 2019-03-06 18:12:39 +01:00 committed by GitHub
commit 3ccf73b3eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 1 deletions

View File

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

View File

@ -252,6 +252,15 @@ string TestFileParser::parseIdentifierOrTuple()
{ {
identOrTuple = m_scanner.currentLiteral(); identOrTuple = m_scanner.currentLiteral();
expect(Token::Identifier); expect(Token::Identifier);
while (accept(Token::LBrack))
{
identOrTuple += formatToken(Token::LBrack);
expect(Token::LBrack);
if (accept(Token::Number))
identOrTuple += parseDecimalNumber();
identOrTuple += formatToken(Token::RBrack);
expect(Token::RBrack);
}
return identOrTuple; return identOrTuple;
} }
expect(Token::LParen); expect(Token::LParen);
@ -402,6 +411,12 @@ void TestFileParser::Scanner::scanNextToken()
case ')': case ')':
token = selectToken(Token::RParen); token = selectToken(Token::RParen);
break; break;
case '[':
token = selectToken(Token::LBrack);
break;
case ']':
token = selectToken(Token::RBrack);
break;
default: default:
if (langutil::isIdentifierStart(current())) if (langutil::isIdentifierStart(current()))
{ {

View File

@ -460,6 +460,20 @@ BOOST_AUTO_TEST_CASE(call_multiple_arguments_mixed_format)
); );
} }
BOOST_AUTO_TEST_CASE(call_signature_array)
{
char const* source = R"(
// f(uint256[]) ->
// f(uint256[3]) ->
// f(uint256[3][][], uint8[9]) ->
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 3);
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[3][][],uint8[9])", false);
}
BOOST_AUTO_TEST_CASE(call_signature_valid) BOOST_AUTO_TEST_CASE(call_signature_valid)
{ {
char const* source = R"( char const* source = R"(