mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update parser test expectations
This commit is contained in:
parent
cc10839073
commit
840ed1e88a
@ -212,10 +212,10 @@ BOOST_AUTO_TEST_CASE(tokens_as_identifers)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(lacking_types)
|
BOOST_AUTO_TEST_CASE(lacking_types)
|
||||||
{
|
{
|
||||||
CHECK_ERROR("{ let x := 1:u256 }", ParserError, "Expected token Identifier got 'Assign'");
|
CHECK_ERROR("{ let x := 1:u256 }", ParserError, "Expected identifier but got '='");
|
||||||
CHECK_ERROR("{ let x:u256 := 1 }", ParserError, "Expected token Colon got 'RBrace'");
|
CHECK_ERROR("{ let x:u256 := 1 }", ParserError, "Expected ':' but got '}'");
|
||||||
CHECK_ERROR("{ function f(a) {} }", ParserError, "Expected token Colon got 'RParen'");
|
CHECK_ERROR("{ function f(a) {} }", ParserError, "Expected ':' but got ')'");
|
||||||
CHECK_ERROR("{ function f(a:u256) -> b {} }", ParserError, "Expected token Colon got 'LBrace'");
|
CHECK_ERROR("{ function f(a:u256) -> b {} }", ParserError, "Expected ':' but got '{'");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(invalid_types)
|
BOOST_AUTO_TEST_CASE(invalid_types)
|
||||||
@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(if_statement)
|
|||||||
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
||||||
{
|
{
|
||||||
CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected.");
|
CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected.");
|
||||||
CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected token LBrace");
|
CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected '{' but got reserved keyword 'let'");
|
||||||
// TODO change this to an error once we check types.
|
// TODO change this to an error once we check types.
|
||||||
BOOST_CHECK(successParse("{ if 42:u256 { } }"));
|
BOOST_CHECK(successParse("{ if 42:u256 { } }"));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(surplus_input)
|
BOOST_AUTO_TEST_CASE(surplus_input)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ } { }", ParserError, "Expected token EOS");
|
CHECK_PARSE_ERROR("{ } { }", ParserError, "Expected end of source but got '{'");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(simple_instructions)
|
BOOST_AUTO_TEST_CASE(simple_instructions)
|
||||||
@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(functional)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(functional_partial)
|
BOOST_AUTO_TEST_CASE(functional_partial)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ let x := byte }", ParserError, "Expected token \"(\"");
|
CHECK_PARSE_ERROR("{ let x := byte }", ParserError, "Expected '(' (instruction \"byte\" expects 2 arguments)");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(functional_partial_success)
|
BOOST_AUTO_TEST_CASE(functional_partial_success)
|
||||||
@ -290,10 +290,10 @@ BOOST_AUTO_TEST_CASE(if_statement_scope)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ if mload {} }", ParserError, "Expected token \"(\"");
|
CHECK_PARSE_ERROR("{ if mload {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
|
||||||
BOOST_CHECK("{ if calldatasize() {}");
|
BOOST_CHECK("{ if calldatasize() {}");
|
||||||
CHECK_PARSE_ERROR("{ if mstore(1, 1) {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
CHECK_PARSE_ERROR("{ if mstore(1, 1) {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
||||||
CHECK_PARSE_ERROR("{ if 32 let x := 3 }", ParserError, "Expected token LBrace");
|
CHECK_PARSE_ERROR("{ if 32 let x := 3 }", ParserError, "Expected '{' but got reserved keyword 'let'");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(switch_statement)
|
BOOST_AUTO_TEST_CASE(switch_statement)
|
||||||
@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
|||||||
BOOST_AUTO_TEST_CASE(switch_invalid_expression)
|
BOOST_AUTO_TEST_CASE(switch_invalid_expression)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ switch {} default {} }", ParserError, "Literal, identifier or instruction expected.");
|
CHECK_PARSE_ERROR("{ switch {} default {} }", ParserError, "Literal, identifier or instruction expected.");
|
||||||
CHECK_PARSE_ERROR("{ switch mload default {} }", ParserError, "Expected token \"(\"");
|
CHECK_PARSE_ERROR("{ switch mload default {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
|
||||||
CHECK_PARSE_ERROR("{ switch mstore(1, 1) default {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
CHECK_PARSE_ERROR("{ switch mstore(1, 1) default {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(switch_invalid_case)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(switch_invalid_body)
|
BOOST_AUTO_TEST_CASE(switch_invalid_body)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ switch 42 case 1 mul case 2 {} default {} }", ParserError, "Expected token LBrace got 'Identifier'");
|
CHECK_PARSE_ERROR("{ switch 42 case 1 mul case 2 {} default {} }", ParserError, "Expected '{' but got identifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(for_statement)
|
BOOST_AUTO_TEST_CASE(for_statement)
|
||||||
@ -353,10 +353,10 @@ BOOST_AUTO_TEST_CASE(for_statement)
|
|||||||
BOOST_AUTO_TEST_CASE(for_invalid_expression)
|
BOOST_AUTO_TEST_CASE(for_invalid_expression)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ for {} {} {} {} }", ParserError, "Literal, identifier or instruction expected.");
|
CHECK_PARSE_ERROR("{ for {} {} {} {} }", ParserError, "Literal, identifier or instruction expected.");
|
||||||
CHECK_PARSE_ERROR("{ for 1 1 {} {} }", ParserError, "Expected token LBrace got 'Number'");
|
CHECK_PARSE_ERROR("{ for 1 1 {} {} }", ParserError, "Expected '{' but got 'Number'");
|
||||||
CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected token LBrace got 'Number'");
|
CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected '{' but got 'Number'");
|
||||||
CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected token LBrace got 'Number'");
|
CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected '{' but got 'Number'");
|
||||||
CHECK_PARSE_ERROR("{ for {} mload {} {} }", ParserError, "Expected token \"(\"");
|
CHECK_PARSE_ERROR("{ for {} mload {} {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
|
||||||
CHECK_PARSE_ERROR("{ for {} mstore(1, 1) {} {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
CHECK_PARSE_ERROR("{ for {} mstore(1, 1) {} {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,13 +437,13 @@ BOOST_AUTO_TEST_CASE(invalid_tuple_assignment)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(instruction_too_few_arguments)
|
BOOST_AUTO_TEST_CASE(instruction_too_few_arguments)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ mul() }", ParserError, "Expected expression (\"mul\" expects 2 arguments)");
|
CHECK_PARSE_ERROR("{ mul() }", ParserError, "Expected expression (instruction \"mul\" expects 2 arguments)");
|
||||||
CHECK_PARSE_ERROR("{ mul(1) }", ParserError, "Expected comma (\"mul\" expects 2 arguments)");
|
CHECK_PARSE_ERROR("{ mul(1) }", ParserError, "Expected ',' (instruction \"mul\" expects 2 arguments)");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(instruction_too_many_arguments)
|
BOOST_AUTO_TEST_CASE(instruction_too_many_arguments)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ mul(1, 2, 3) }", ParserError, "Expected ')' (\"mul\" expects 2 arguments)");
|
CHECK_PARSE_ERROR("{ mul(1, 2, 3) }", ParserError, "Expected ')' (instruction \"mul\" expects 2 arguments)");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(recursion_depth)
|
BOOST_AUTO_TEST_CASE(recursion_depth)
|
||||||
|
@ -992,7 +992,7 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
|
|||||||
for (const auto& keyword: keywords)
|
for (const auto& keyword: keywords)
|
||||||
{
|
{
|
||||||
auto text = std::string("contract ") + keyword + " {}";
|
auto text = std::string("contract ") + keyword + " {}";
|
||||||
CHECK_PARSE_ERROR(text.c_str(), "Expected token Identifier got reserved keyword");
|
CHECK_PARSE_ERROR(text.c_str(), "Expected identifier but got reserved keyword");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,8 +326,8 @@ BOOST_AUTO_TEST_CASE(compilation_error)
|
|||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(
|
BOOST_CHECK_EQUAL(
|
||||||
dev::jsonCompactPrint(error),
|
dev::jsonCompactPrint(error),
|
||||||
"{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected token Identifier got 'RBrace'\\n"
|
"{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected identifier but got '}'\\n"
|
||||||
"contract A { function }\\n ^\\n\",\"message\":\"Expected token Identifier got 'RBrace'\","
|
"contract A { function }\\n ^\\n\",\"message\":\"Expected identifier but got '}'\","
|
||||||
"\"severity\":\"error\",\"sourceLocation\":{\"end\":22,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}"
|
"\"severity\":\"error\",\"sourceLocation\":{\"end\":22,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (118-118): Expected token Semicolon got 'Identifier'
|
// ParserError: (118-118): Expected ';' but got identifier
|
||||||
|
@ -2,4 +2,4 @@ contract Foo {
|
|||||||
uint constant = 4;
|
uint constant = 4;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (30-30): Expected token Identifier got 'Assign'
|
// ParserError: (30-30): Expected identifier but got '='
|
||||||
|
@ -5,4 +5,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (49-49): Expected token LParen got 'Semicolon'
|
// ParserError: (49-49): Expected '(' but got ';'
|
||||||
|
@ -2,4 +2,4 @@ contract c {
|
|||||||
event e;
|
event e;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (21-21): Expected token LParen got 'Semicolon'
|
// ParserError: (21-21): Expected '(' but got ';'
|
||||||
|
@ -2,4 +2,4 @@ contract c {
|
|||||||
uint external x;
|
uint external x;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (19-19): Expected token Identifier got 'External'
|
// ParserError: (19-19): Expected identifier but got 'external'
|
||||||
|
@ -2,4 +2,4 @@ contract A {
|
|||||||
fixed40x40 pi = 3.14.15;
|
fixed40x40 pi = 3.14.15;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (34-34): Expected token Semicolon got 'Number'
|
// ParserError: (34-34): Expected ';' but got 'Number'
|
||||||
|
@ -2,4 +2,4 @@ contract test {
|
|||||||
function (uint, uint) modifier1() returns (uint) f1;
|
function (uint, uint) modifier1() returns (uint) f1;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (66-66): Expected token LBrace got 'Identifier'
|
// ParserError: (66-66): Expected '{' but got identifier
|
||||||
|
@ -6,4 +6,4 @@ contract Foo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (67-67): Expected token Semicolon got 'Constant'
|
// ParserError: (67-67): Expected ';' but got 'constant'
|
||||||
|
@ -2,4 +2,4 @@ contract Foo {
|
|||||||
uint[] memory x;
|
uint[] memory x;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (23-23): Expected token Identifier got 'Memory'
|
// ParserError: (23-23): Expected identifier but got 'memory'
|
||||||
|
@ -2,4 +2,4 @@ contract c {
|
|||||||
enum foo { WARNING,}
|
enum foo { WARNING,}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (33-33): Expected Identifier after ','
|
// ParserError: (33-33): Expected identifier after ','
|
||||||
|
@ -3,4 +3,4 @@ contract test {
|
|||||||
function b() returns (uint r) { r = a({: 1, : 2, : 3}); }
|
function b() returns (uint r) { r = a({: 1, : 2, : 3}); }
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (143-143): Expected token Identifier got 'Colon'
|
// ParserError: (143-143): Expected identifier but got ':'
|
||||||
|
@ -2,4 +2,4 @@ contract test {
|
|||||||
uint256 ;
|
uint256 ;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (28-28): Expected token Identifier got 'Semicolon'
|
// ParserError: (28-28): Expected identifier but got ';'
|
||||||
|
@ -2,4 +2,4 @@ contract c {
|
|||||||
modifier mod { if (msg.sender == 0) _ }
|
modifier mod { if (msg.sender == 0) _ }
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (52-52): Expected token Semicolon got 'RBrace'
|
// ParserError: (52-52): Expected ';' but got '}'
|
||||||
|
@ -2,4 +2,4 @@ contract test {
|
|||||||
uint payable x;
|
uint payable x;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (22-22): Expected token Identifier got 'Payable'
|
// ParserError: (22-22): Expected identifier but got 'payable'
|
||||||
|
@ -4,4 +4,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (42-42): Expected token Comma got 'Number'
|
// ParserError: (42-42): Expected ',' but got 'Number'
|
||||||
|
@ -2,4 +2,4 @@ contract Foo {
|
|||||||
function f() { var[] a; }
|
function f() { var[] a; }
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// ParserError: (34-34): Expected token Identifier got 'LBrack'
|
// ParserError: (34-34): Expected identifier but got '['
|
||||||
|
Loading…
Reference in New Issue
Block a user