diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index cbea86946..0c801cf62 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -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() } diff --git a/test/libsolidity/syntaxTests/parsing/comment_end_with_double_star.sol b/test/libsolidity/syntaxTests/parsing/comment_end_with_double_star.sol new file mode 100644 index 000000000..d3fcae9be --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/comment_end_with_double_star.sol @@ -0,0 +1,5 @@ +contract C1 { +/** + **/ +} +contract C2 {} diff --git a/test/libsolidity/syntaxTests/parsing/empty_comment.sol b/test/libsolidity/syntaxTests/parsing/empty_comment.sol new file mode 100644 index 000000000..b39c8483d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/empty_comment.sol @@ -0,0 +1,3 @@ +// +contract test +{} diff --git a/test/libsolidity/syntaxTests/parsing/function_no_body.sol b/test/libsolidity/syntaxTests/parsing/function_no_body.sol new file mode 100644 index 000000000..0424ebd89 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_no_body.sol @@ -0,0 +1,5 @@ +contract test { + function functionName(bytes32 input) returns (bytes32 out); +} +// ---- +// Warning: (17-76): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/function_type_state_variable.sol b/test/libsolidity/syntaxTests/parsing/function_type_state_variable.sol new file mode 100644 index 000000000..eff52c7ca --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/function_type_state_variable.sol @@ -0,0 +1,4 @@ +contract test { + function() x; + function() y = x; +} \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol new file mode 100644 index 000000000..c25b48bae --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol new file mode 100644 index 000000000..818999dff --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol @@ -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 diff --git a/test/libsolidity/syntaxTests/parsing/multiple_function_param_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_function_param_trailing_comma.sol new file mode 100644 index 000000000..ae65b33ca --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/multiple_function_param_trailing_comma.sol @@ -0,0 +1,5 @@ +contract test { + function(uint a, uint b,) {} +} +// ---- +// ParserError: (40-41): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol new file mode 100644 index 000000000..1a78d1551 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol @@ -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 diff --git a/test/libsolidity/syntaxTests/parsing/single_event_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/single_event_arg_trailing_comma.sol new file mode 100644 index 000000000..50638dc7c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/single_event_arg_trailing_comma.sol @@ -0,0 +1,6 @@ +contract test { + event Test(uint a,); + function(uint a) {} +} +// ---- +// ParserError: (34-35): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/single_modifier_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/single_modifier_arg_trailing_comma.sol new file mode 100644 index 000000000..2f60405ff --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/single_modifier_arg_trailing_comma.sol @@ -0,0 +1,6 @@ +contract test { + modifier modTest(uint a,) { _; } + function(uint a) {} +} +// ---- +// ParserError: (40-41): Unexpected trailing comma in parameter list. diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol new file mode 100644 index 000000000..6f7397406 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -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