mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move couple of parser tests to syntax tests.
This commit is contained in:
parent
2ba0002998
commit
7fb43fe854
@ -112,38 +112,6 @@ while(0)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(SolidityParser)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(single_modifier_arg_trailing_comma)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
modifier modTest(uint a,) { _; }
|
||||
function(uint a) {}
|
||||
}
|
||||
)";
|
||||
CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(single_event_arg_trailing_comma)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
event Test(uint a,);
|
||||
function(uint a) {}
|
||||
}
|
||||
)";
|
||||
CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multiple_function_param_trailing_comma)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function(uint a, uint b,) {}
|
||||
}
|
||||
)";
|
||||
CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multiple_return_param_trailing_comma)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -176,16 +144,6 @@ BOOST_AUTO_TEST_CASE(multiple_event_arg_trailing_comma)
|
||||
CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_no_body)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function functionName(bytes32 input) returns (bytes32 out);
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(two_exact_functions)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -200,17 +158,6 @@ BOOST_AUTO_TEST_CASE(two_exact_functions)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(overloaded_functions)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function fun(uint a) returns(uint r) { return a; }
|
||||
function fun(uint a, uint b) returns(uint r) { return a + b; }
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -985,28 +932,6 @@ BOOST_AUTO_TEST_CASE(location_specifiers_for_locals)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_comment)
|
||||
{
|
||||
char const* text = R"(
|
||||
//
|
||||
contract test
|
||||
{}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(comment_end_with_double_star)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C1 {
|
||||
/**
|
||||
**/
|
||||
}
|
||||
contract C2 {}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(library_simple)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -1017,42 +942,6 @@ BOOST_AUTO_TEST_CASE(library_simple)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multi_variable_declaration)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
function f() {
|
||||
var (a,b,c) = g();
|
||||
var (d) = 2;
|
||||
var (,e) = 3;
|
||||
var (f,) = 4;
|
||||
var (x,,) = g();
|
||||
var (,y,) = g();
|
||||
var () = g();
|
||||
var (,,) = g();
|
||||
}
|
||||
function g() returns (uint, uint, uint) {}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(tuples)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
function f() {
|
||||
uint a = (1);
|
||||
var (b,) = (1,);
|
||||
var (c,d) = (1, 2 + a);
|
||||
var (e,) = (1, 2, b);
|
||||
(a) = 3;
|
||||
}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -1335,27 +1224,6 @@ BOOST_AUTO_TEST_CASE(mapping_and_array_of_functions)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_type_state_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function() x;
|
||||
function() y = x;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(interface)
|
||||
{
|
||||
char const* text = R"(
|
||||
interface Interface {
|
||||
function f();
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
contract C1 {
|
||||
/**
|
||||
**/
|
||||
}
|
||||
contract C2 {}
|
3
test/libsolidity/syntaxTests/parsing/empty_comment.sol
Normal file
3
test/libsolidity/syntaxTests/parsing/empty_comment.sol
Normal file
@ -0,0 +1,3 @@
|
||||
//
|
||||
contract test
|
||||
{}
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function functionName(bytes32 input) returns (bytes32 out);
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-76): No visibility specified. Defaulting to "public".
|
@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
function() x;
|
||||
function() y = x;
|
||||
}
|
6
test/libsolidity/syntaxTests/parsing/interface_basic.sol
Normal file
6
test/libsolidity/syntaxTests/parsing/interface_basic.sol
Normal file
@ -0,0 +1,6 @@
|
||||
interface Interface {
|
||||
function f();
|
||||
}
|
||||
// ----
|
||||
// Warning: (23-36): Functions in interfaces should be declared external.
|
||||
// Warning: (23-36): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
|
@ -0,0 +1,29 @@
|
||||
contract C {
|
||||
function f() {
|
||||
var (a,b,c) = g();
|
||||
var (d) = 2;
|
||||
var (,e) = 3;
|
||||
var (f,) = 4;
|
||||
var (x,,) = g();
|
||||
var (,y,) = g();
|
||||
var () = g();
|
||||
var (,,) = g();
|
||||
}
|
||||
function g() returns (uint, uint, uint) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (36-37): Use of the "var" keyword is deprecated.
|
||||
// Warning: (38-39): Use of the "var" keyword is deprecated.
|
||||
// Warning: (40-41): Use of the "var" keyword is deprecated.
|
||||
// Warning: (57-58): Use of the "var" keyword is deprecated.
|
||||
// Warning: (73-74): Use of the "var" keyword is deprecated.
|
||||
// Warning: (88-89): Use of the "var" keyword is deprecated.
|
||||
// Warning: (104-105): Use of the "var" keyword is deprecated.
|
||||
// Warning: (124-125): Use of the "var" keyword is deprecated.
|
||||
// Warning: (88-89): This declaration shadows an existing declaration.
|
||||
// Warning: (52-63): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// Warning: (67-79): Different number of components on the left hand side (2) than on the right hand side (1).
|
||||
// Warning: (67-79): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// Warning: (83-95): Different number of components on the left hand side (2) than on the right hand side (1).
|
||||
// Warning: (83-95): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// TypeError: (137-149): Too many components (3) in value for variable assignment (0) needed
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function(uint a, uint b,) {}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (40-41): Unexpected trailing comma in parameter list.
|
@ -0,0 +1,9 @@
|
||||
contract test {
|
||||
function fun(uint a) returns(uint r) { return a; }
|
||||
function fun(uint a, uint b) returns(uint r) { return a + b; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-67): No visibility specified. Defaulting to "public".
|
||||
// Warning: (69-131): No visibility specified. Defaulting to "public".
|
||||
// Warning: (17-67): Function state mutability can be restricted to pure
|
||||
// Warning: (69-131): Function state mutability can be restricted to pure
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
event Test(uint a,);
|
||||
function(uint a) {}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (34-35): Unexpected trailing comma in parameter list.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
modifier modTest(uint a,) { _; }
|
||||
function(uint a) {}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (40-41): Unexpected trailing comma in parameter list.
|
24
test/libsolidity/syntaxTests/parsing/tuples.sol
Normal file
24
test/libsolidity/syntaxTests/parsing/tuples.sol
Normal file
@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
function f() {
|
||||
uint a = (1);
|
||||
var (b,) = (1,);
|
||||
var (c,d) = (1, 2 + a);
|
||||
var (e,) = (1, 2, b);
|
||||
(a) = 3;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (52-53): Use of the "var" keyword is deprecated.
|
||||
// Warning: (71-72): Use of the "var" keyword is deprecated.
|
||||
// Warning: (73-74): Use of the "var" keyword is deprecated.
|
||||
// Warning: (97-98): Use of the "var" keyword is deprecated.
|
||||
// Warning: (47-62): Different number of components on the left hand side (2) than on the right hand side (1).
|
||||
// Warning: (47-62): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// Warning: (66-88): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// Warning: (92-112): Different number of components on the left hand side (2) than on the right hand side (3).
|
||||
// Warning: (92-112): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
|
||||
// Warning: (14-127): No visibility specified. Defaulting to "public".
|
||||
// Warning: (71-72): Unused local variable.
|
||||
// Warning: (73-74): Unused local variable.
|
||||
// Warning: (97-98): Unused local variable.
|
||||
// Warning: (14-127): Function state mutability can be restricted to pure
|
Loading…
Reference in New Issue
Block a user