mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
isoltest: Makes ->
declaration optional.
This commit is contained in:
parent
508cf66da2
commit
8c51a089d7
@ -6,6 +6,9 @@ contract C {
|
|||||||
function balance() payable public returns (uint256) {
|
function balance() payable public returns (uint256) {
|
||||||
return address(this).balance;
|
return address(this).balance;
|
||||||
}
|
}
|
||||||
|
function e(uint a) public {
|
||||||
|
state = a;
|
||||||
|
}
|
||||||
function f() payable public returns (uint) {
|
function f() payable public returns (uint) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -45,6 +48,7 @@ contract C {
|
|||||||
// state() -> 3
|
// state() -> 3
|
||||||
// balance() -> 2
|
// balance() -> 2
|
||||||
// _() -> FAILURE
|
// _() -> FAILURE
|
||||||
|
// e(uint256): 4
|
||||||
// f() -> 2
|
// f() -> 2
|
||||||
// f(), 1 ether -> 2
|
// f(), 1 ether -> 2
|
||||||
// g() -> 2, 3
|
// g() -> 2, 3
|
||||||
|
@ -249,6 +249,9 @@ struct FunctionCall
|
|||||||
DisplayMode displayMode = DisplayMode::SingleLine;
|
DisplayMode displayMode = DisplayMode::SingleLine;
|
||||||
/// Marks this function call as the constructor.
|
/// Marks this function call as the constructor.
|
||||||
bool isConstructor = false;
|
bool isConstructor = false;
|
||||||
|
/// Marks this function call as "short-handed", meaning
|
||||||
|
/// no `->` declared.
|
||||||
|
bool omitsArrow = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,19 @@ vector<dev::solidity::test::FunctionCall> TestFileParser::parseFunctionCalls(siz
|
|||||||
m_lineNumber++;
|
m_lineNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(Token::Arrow);
|
if (accept(Token::Arrow, true))
|
||||||
|
{
|
||||||
|
call.omitsArrow = false;
|
||||||
call.expectations = parseFunctionCallExpectations();
|
call.expectations = parseFunctionCallExpectations();
|
||||||
|
|
||||||
if (accept(Token::Newline, true))
|
if (accept(Token::Newline, true))
|
||||||
m_lineNumber++;
|
m_lineNumber++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
call.expectations.failure = false;
|
||||||
|
call.displayMode = FunctionCall::DisplayMode::SingleLine;
|
||||||
|
}
|
||||||
|
|
||||||
call.expectations.comment = parseComment();
|
call.expectations.comment = parseComment();
|
||||||
|
|
||||||
if (call.signature == "constructor()")
|
if (call.signature == "constructor()")
|
||||||
|
@ -695,13 +695,6 @@ BOOST_AUTO_TEST_CASE(call_arguments_tuple_invalid_parantheses)
|
|||||||
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
|
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(call_expectations_missing)
|
|
||||||
{
|
|
||||||
char const* source = R"(
|
|
||||||
// f())";
|
|
||||||
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(call_ether_value_expectations_missing)
|
BOOST_AUTO_TEST_CASE(call_ether_value_expectations_missing)
|
||||||
{
|
{
|
||||||
char const* source = R"(
|
char const* source = R"(
|
||||||
@ -803,7 +796,7 @@ BOOST_AUTO_TEST_CASE(call_arguments_newline_colon)
|
|||||||
BOOST_AUTO_TEST_CASE(call_arrow_missing)
|
BOOST_AUTO_TEST_CASE(call_arrow_missing)
|
||||||
{
|
{
|
||||||
char const* source = R"(
|
char const* source = R"(
|
||||||
// h256()
|
// h256() FAILURE
|
||||||
)";
|
)";
|
||||||
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
|
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,18 @@ string TestFunctionCall::format(
|
|||||||
{
|
{
|
||||||
if (!m_call.arguments.comment.empty())
|
if (!m_call.arguments.comment.empty())
|
||||||
stream << ws << comment << m_call.arguments.comment << comment;
|
stream << ws << comment << m_call.arguments.comment << comment;
|
||||||
|
|
||||||
|
if (m_call.omitsArrow)
|
||||||
|
{
|
||||||
|
if (_renderResult && (m_failure || !matchesExpectation()))
|
||||||
stream << ws << arrow << ws;
|
stream << ws << arrow << ws;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
stream << ws << arrow << ws;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
stream << endl << _linePrefix << newline << ws;
|
stream << endl << _linePrefix << newline << ws;
|
||||||
if (!m_call.arguments.comment.empty())
|
if (!m_call.arguments.comment.empty())
|
||||||
|
@ -44,6 +44,8 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
|
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> 1");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> 1");
|
||||||
@ -62,6 +64,8 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline_signed_encoding)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
|
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> 1");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> 1");
|
||||||
@ -80,6 +84,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_multiline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{result}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{result}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{}, string{}};
|
||||||
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
call.displayMode = FunctionCall::DisplayMode::MultiLine;
|
call.displayMode = FunctionCall::DisplayMode::MultiLine;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
@ -94,6 +99,7 @@ BOOST_AUTO_TEST_CASE(format_multiple_unsigned_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param, param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param, param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param, param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param, param}, string{}};
|
||||||
FunctionCall call{"f(uint8, uint8)", 0, arguments, expectations};
|
FunctionCall call{"f(uint8, uint8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8, uint8): 1, 1 -> 1, 1");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8, uint8): 1, 1 -> 1, 1");
|
||||||
@ -107,6 +113,7 @@ BOOST_AUTO_TEST_CASE(format_signed_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(int8)", 0, arguments, expectations};
|
FunctionCall call{"f(int8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(int8): -1 -> -1");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(int8): -1 -> -1");
|
||||||
@ -126,6 +133,7 @@ BOOST_AUTO_TEST_CASE(format_hex_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(bytes32)", 0, arguments, expectations};
|
FunctionCall call{"f(bytes32)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(bytes32): 0x31 -> 0x31");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(bytes32): 0x31 -> 0x31");
|
||||||
@ -146,6 +154,7 @@ BOOST_AUTO_TEST_CASE(format_hex_string_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(string)", 0, arguments, expectations};
|
FunctionCall call{"f(string)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(string): hex\"4200ef\" -> hex\"4200ef\"");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(string): hex\"4200ef\" -> hex\"4200ef\"");
|
||||||
@ -159,6 +168,7 @@ BOOST_AUTO_TEST_CASE(format_bool_true_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): true -> true");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): true -> true");
|
||||||
@ -179,6 +189,7 @@ BOOST_AUTO_TEST_CASE(format_bool_false_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): false -> false");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): false -> false");
|
||||||
@ -192,6 +203,7 @@ BOOST_AUTO_TEST_CASE(format_bool_left_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): left(false) -> left(false)");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): left(false) -> left(false)");
|
||||||
@ -206,6 +218,7 @@ BOOST_AUTO_TEST_CASE(format_hex_number_right_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
FunctionCall call{"f(bool)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): right(0x42) -> right(0x42)");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(bool): right(0x42) -> right(0x42)");
|
||||||
@ -219,6 +232,7 @@ BOOST_AUTO_TEST_CASE(format_empty_byte_range)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{param}, false, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{}, string{}};
|
||||||
FunctionCall call{"f()", 0, arguments, expectations};
|
FunctionCall call{"f()", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f() -> 1");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f() -> 1");
|
||||||
@ -232,6 +246,7 @@ BOOST_AUTO_TEST_CASE(format_failure_singleline)
|
|||||||
FunctionCallExpectations expectations{vector<Parameter>{}, true, string{}};
|
FunctionCallExpectations expectations{vector<Parameter>{}, true, string{}};
|
||||||
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
FunctionCallArgs arguments{vector<Parameter>{param}, string{}};
|
||||||
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
FunctionCall call{"f(uint8)", 0, arguments, expectations};
|
||||||
|
call.omitsArrow = false;
|
||||||
TestFunctionCall test{call};
|
TestFunctionCall test{call};
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> FAILURE");
|
BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8): 1 -> FAILURE");
|
||||||
|
Loading…
Reference in New Issue
Block a user